Search code examples
imagemagickimagemagick-convert

-flatten option use in ImageMagick


My program uses ImageMagick to convert a multipage tiff to pdf.

convert.exe "C:\multipage_tiff_example.tif" -flatten "pdf:C:\cache\multipage_tiff_example-636946171.pdf"

Issue

If I use -flatten in the above command for multipage tiff files, it only renders the first page of the tiff to pdf.

And removing -flatten, gives the correct PDF rendition for all the pages.

My doubt

I read about the -flatten option here as well. But I am unable to understand why it only gives a single page in the rendition.


Solution

  • That's what "-flatten" does. It takes a sequence of images, composes them one at a time against the previous image(s), taking transparency into account, resulting in a single opaque composite image.

    If you wanted a series of images to be output, each composed against the preceding image(s), then use the "-coalesce" option instead.