1

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?

ipsi
  • 2,049
  • 18
  • 23
  • If you are looking for Java solution refer: https://stackoverflow.com/questions/1954685/cant-read-and-write-a-tiff-image-file-using-java-imageio-standard-library/62132533#62132533 – Sandeep Kumar Jun 01 '20 at 12:51

1 Answers1

1

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
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • I will poke it with a stick again. Though, thinking about it, it might be worth converting each image to a MIFF first, then piping all of those through to IM. Thanks for the suggestion! – ipsi May 24 '16 at 14:04
  • I guess there's a reason why `MIFF` is ImageMagick's streaming file format... ;-) – Mark Setchell May 24 '16 at 14:12
  • Converting them all to `MIFF`, then merging them into a single `byte[]`, then sending that through works as expected. Just tried again with JPGs and it does not work. – ipsi May 24 '16 at 14:13