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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
alasdairdf
Posts: 53
Joined: 2012-05-15T04:56:50-07:00
Authentication code: 13

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

Post 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?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post 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
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
alasdairdf
Posts: 53
Joined: 2012-05-15T04:56:50-07:00
Authentication code: 13

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

Post by alasdairdf »

Yeah, tried that already and the resulting TIF image was identical. Thanks, though.
alasdairdf
Posts: 53
Joined: 2012-05-15T04:56:50-07:00
Authentication code: 13

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

Post 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.
Post Reply