I'm trying to pass the convert arguments as string to in() without success.
works fine if I run this:
const GM = require('gm');
const gm = GM.subClass({ imageMagick: true });
gm(buf).command('convert').in('-resize','800x','-resize','800x','-sharpen','0x.4','-crop','160x180+0+0','+repage','-quality','92').toBuffer((err, buffer) => err ? reject(err) : resolve(buffer));
But not if I run:
const GM = require('gm');
const gm = GM.subClass({ imageMagick: true });
let command = "'-resize','800x','-resize','800x','-sharpen','0x.4','-crop','160x180+0+0','+repage','-quality','92'";
gm(buf).command('convert').in(command).toBuffer((err, buffer) => err ? reject(err) : resolve(buffer));
seems to just ignore the command altogether.
The reason I'm attempting to pass the command as a string is that I ultimately want to pass the command to lambda node as an event. ie "event.command"
I've faced the same problem recently. aws-lambda-image is used to process images on the Lambda function. It and the underlying ImageMagick library do not support every capability of ImageMagick. In GraphicMagic for node, you have to build a chain of operators as shown in this example.
However, as in your situation, we may have very complex queries and we don't want to add a new operator for every different query. Therefore, I wrote a converter that converts raw imagemagick
convertquery into GM's chain of operators. It works like below:You can also create ImageConverter like ImageResizer to use in your aws-lambda-image function. In this case, only you need to do is:
Check my gist to see the script: https://gist.github.com/farukcankaya/5b698044d907fe80a7c1f6e3afe618bc