Search code examples
javaimagemagickimagemagick-convert

Merging multiple JPGs from stdin into multi-file TIFF


I currently have the following command line with ImageMagick:

convert jpg:- -density 200x200 -monochrome -colors 2 -compress Group4 tif:-

I would like to be able to pipe more than one JPG image in stdin, and have those merged into a multi-file TIFF

More precisely, I am doing this from Java via ProcessBuilder, so I am not able to (easily or safely) do things like convert jpg:fd1 ....

I have tried merging all the JPG files into a single byte[] in Java and writing that to the sub-processes stdin, but the result was that ImageMagick only processed the first JPG.

Is what I want to do possible?


Solution

  • I don't know why that doesn't work as you have it, but for the moment, while I am thinking about it, the following does work and may be of use:

    for f in *.jpg; do convert "$f" miff:- ; done | convert miff:- result.tif