Problem with compression on TIF files

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?".
Locked
Spud
Posts: 4
Joined: 2013-11-10T09:16:33-07:00
Authentication code: 6789

Problem with compression on TIF files

Post by Spud »

Hi, folks. I'm new to ImageMagick and just starting to get to grips with what it can do.

However, I have hit a problem that I can't seem to find a solution for - I'm hoping one of you gurus out there can help me.

What I'm trying to do is conceptually quite simple - I'm trying to convert PDF files (some single, some multi-page) to compressed 300 dpi TIF files (multi-page where necessary).

All works well if I do a:

convert -density 300 file1.pdf file2.tif

However, this creates a huge tif file - that's why I want to compress (ideally with Group4).

So I try a:

convert -density 300 -compress Group4 file1.pdf file2.tif

It produces a tif file, but when I view it in Office viewer (or paste it into Word), it is a sickly green colour. I've tried the same command with zip compression, and this produces an image with a beige background. I've tried playing around with all sorts of background and transparency settings, but I haven't found anything that makes any difference.

I've tried splitting the command into 2. If I do the convert uncompressed I get a large (but otherwise OK) tif file. If I then try to compress that tif file, I'm back to the green background - so it looks like it is the compression that is causing the issue.

Any help would be much appreciated.

Thanks.

User avatar
dlemstra
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Problem with compression on TIF files

Post by dlemstra »

What version of ImageMagick are you using? And can you post a link to your pdf file?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with compression on TIF files

Post by fmw42 »

You can do supersampling to keep the same size image.

convert -density 288 file1.pdf -resize 25% file2.tif

72*4=288 so resize by 25%=1/4

Spud
Posts: 4
Joined: 2013-11-10T09:16:33-07:00
Authentication code: 6789

Re: Problem with compression on TIF files

Post by Spud »

Thanks for the suggestion fmw42. However, the background I now get is beige (the same as if I use zip compression). The file size is still also fairly large - the original (uncompressed) tif file comes in at a whopping 33MB and the Group4 compressed tif is only 36KB. The 25% resized tif is 1.9MB, so much smaller than uncompressed but still a fair bit larger than I'm really after.

Thanks.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with compression on TIF files

Post by fmw42 »

Does your pdf have an imbedded image (rather than just vector data) and if so is it cmyk?

identify -verbose image.pdf

Can you provide the output from the above or provide your pdf image. You can post to some free image hosting service such as dropbox and then put a link here.

Spud
Posts: 4
Joined: 2013-11-10T09:16:33-07:00
Authentication code: 6789

Re: Problem with compression on TIF files

Post by Spud »

Thanks dlemstra and fmw42.

I'm using ImageMagick version 6.8.2-3, although I have also tried 6.8.7-5 and had the same problem.

Here is a link to the files - I've attached the pds and the tif. The tif looks white, but if you download it and paste into Word it is green.

https://skydrive.live.com/?cid=2ef743ec ... 00E4%21250

There are no embedded images - this pdf came straight off a scanner. However, I've noticed that if I use the compress option with pdfs created from sources such as Word I don't have the same problem - so it looks like it is something to do with the scanned image.

I haven't posted the identify results here yet - they are quite long. If they are still needed, please let me know.

Thanks.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with compression on TIF files

Post by fmw42 »

I see nothing wrong with either of your files. The tiff file opens fine in 4 different viewers on my Mac. I also pasted into Word 12.3.4 on my Mac and there is no green.

Spud
Posts: 4
Joined: 2013-11-10T09:16:33-07:00
Authentication code: 6789

Re: Problem with compression on TIF files

Post by Spud »

I have finally found a solution/workaround for this - I thought I would post it here in case anyone else has a similar problem.

I seems that the use of (at least) the Group4 and zip compression options is giving erroneous results in the TIF tags. I was able to correct the colour problems by manually setting the 013E (white point) and 013F (primary chromaticities) to 0. It doesn't appear possible to set these tags directly with ImageMagick, but I found that if I set a -green-primary 1.57856,1.62851 option (I got these values from a 'good' tif image) the green goes away.

I am assuming that this is a bug in ImageMagick.

Hope this helps someone.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with compression on TIF files

Post by fmw42 »

Spud wrote:I have finally found a solution/workaround for this - I thought I would post it here in case anyone else has a similar problem.

I seems that the use of (at least) the Group4 and zip compression options is giving erroneous results in the TIF tags. I was able to correct the colour problems by manually setting the 013E (white point) and 013F (primary chromaticities) to 0. It doesn't appear possible to set these tags directly with ImageMagick, but I found that if I set a -green-primary 1.57856,1.62851 option (I got these values from a 'good' tif image) the green goes away.

I am assuming that this is a bug in ImageMagick.

Hope this helps someone.

IM relies upon the libtiff. But it you think this is a bug, please report it to the bugs forum.

Did you try setting the white point via -white-point. see http://www.imagemagick.org/script/comma ... hite-point also http://www.imagemagick.org/script/comma ... mpensation (not sure why the function names are not syntax equivalent?)

User avatar
whugemann
Posts: 313
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Problem with compression on TIF files

Post by whugemann »

I can verify the bug, but not the suggested work-around via -green-primary. I tried to place this option at various points of the command line, but with no effect on the resulting TIFF. It is correct that the effect only affects group4 coded TIFFs. My workaround is to open the files with IrfanView and saving them once again.

And yes, the image is displayed with a white background in every image editor I tried, only MS Word displays it with a green backgound.
Wolfgang Hugemann

User avatar
whugemann
Posts: 313
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: Problem with compression on TIF files

Post by whugemann »

I have just found out that this problem does not affect all PDFs. But I have some (small) PDFs that definitively produce this problem and could provide them for a closer inspection.
Wolfgang Hugemann

Locked