Page 1 of 1

Convert image to TIF Group4 for embedding in PDF - image format is incorrect

Posted: 2015-04-24T06:58:34-07:00
by alasdairdf
Hello,

I'm converting PBMs to TIF Group 4 so they can be embedded into a PDF (I'm creating the TIFs with ImageMagick but not the PDF). The command I am using is:
convert image.pbm -compress Group4 image.tif

However, neither Acrobat, SumatraPDF nor Ghostscript will read any of the PDFs containing these TIF images, even though they are set correctly with the Filter as CCITTFaxDecode and the DecodeParms set to K -1 (for TIF Group 4).

If I generate the same PDF using Ghostscript it does work, and I can see that each TIF image in the Ghostscript PDF (with TIFs generated by Ghostscript) is exactly 171 bytes smaller than each of the ImageMagick generated TIF images.

It seems like ImageMagick is adding additional header information which should not be present for a PDF-embedded TIF file. Exactly 171 bytes difference every single time. However, it does not appear to be the first 171 bytes so I can't just remove it.

Additionally, if I use ImageMagick to convert the above image.tif (generated with ImageMagick) into a PDF, then it is also completely changed and 171 bytes smaller. So obviously there is something going on here.

Is there a way I can generate the same headerless TIF Group 4 using ImageMagick?

Re: Convert image to TIF Group4 for embedding in PDF - image format is incorrect

Posted: 2015-04-24T07:07:33-07:00
by dlemstra
Maybe there is a profile in the image that is not compatible? What happens when you remove all the profiles?

Code: Select all

convert image.pbm -compress Group4 -strip image.tif

Re: Convert image to TIF Group4 for embedding in PDF - image format is incorrect

Posted: 2015-04-24T07:11:12-07:00
by alasdairdf
Yeah, tried that already and the resulting TIF image was identical. Thanks, though.

Re: Convert image to TIF Group4 for embedding in PDF - image format is incorrect

Posted: 2015-04-24T07:41:50-07:00
by alasdairdf
I figured out that if I remove the first 8 bytes and the last 163 bytes then it's the same as the Ghostscript generated TIF and that works. So this can be closed.