So, the code above is supposed to crop the given image and then execute the identify. But actually only the identify command is getting called.
Testing a bit and looking into the gm source, it seems that the crop function adds some params to an _out property but not execute it until write, stream or toBuffer is called.
To test it easier, I extracted those lines into a separate file. Here is what I tried:
const result = gm('some_image.png').crop(1, 1).identify((err, response) => {
console.log(response);
});
With debug on, only the following command is executed:
gm identify "-ping" "-verbose" "some_image.png"
From getPixelColor.js file:
So, the code above is supposed to crop the given image and then execute the identify. But actually only the identify command is getting called.
Testing a bit and looking into the gm source, it seems that the crop function adds some params to an _out property but not execute it until write, stream or toBuffer is called.
To test it easier, I extracted those lines into a separate file. Here is what I tried:
With debug on, only the following command is executed:
gm identify "-ping" "-verbose" "some_image.png"
The result var value is:
The crop command is still there, not executed. And the response from the identify:
2208x2208 is the actual size of the image I used. Now, if I call toBuffer before identify, like:
Then both these command are executed:
Result var value:
Now _out is empty, the crop was executed. And the identify response is:
Applying the change too getPixelColor.js it correctly crops before identifying.