Home > Blockchain >  imagemagick convert -crop with pipe before it
imagemagick convert -crop with pipe before it

Time:03-22

I want to use imagemagick to crop an image. However, imagemagick will be receiving the image data to crop through a pipe before it:

exiftool -b -RawThermalImage image1.jpg | convert .....-crop.....

I am not sure what to put in the ".....-crop.....", to crop the image data received to a specific area. Please guide.

Usually, after convert, an image is specified for cropping like:

convert rose: -crop 1x1 3 3 cropped.gif

But, in this case, I am confused as to how to complete this command given that the image is coming in from the pipe.

ImageLink: https://drive.google.com/file/d/14h3z0yFK_9_f2puzbhLUm3D50MDMMnu2/view?usp=sharing

CodePudding user response:

Updated Answer

It transpires that the problem was caused by inadvertently using GraphicsMagick rather than ImageMagick.

Original Answer

You should be able to use a dash - to refer to the stdin if that stream has a well-known magic number (signature) at the start:

exiftool -b -RawThermalImage image1.jpg | convert - -crop ... result.jpg

If the stream is raw, or doesn't have a known magic number/signature, you will need to give ImageMagick a hint, so if it is raw greyscale 8-bit data with shape 640x480, use:

exiftool -b -RawThermalImage image1.jpg | convert -size 640x480 -depth 8 GRAY:- -crop ... result.jpg

If it's RGB888 data with size 80x80, use:

exiftool -b -RawThermalImage image1.jpg | convert -depth 8 -size 80x80 RGB:- -crop ... result.jpg
  • Related