Page 1 of 1

Problem with compression on TIF files

Posted: 2013-11-10T09:31:49-07:00
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.

Re: Problem with compression on TIF files

Posted: 2013-11-10T10:10:58-07:00
by dlemstra
What version of ImageMagick are you using? And can you post a link to your pdf file?

Re: Problem with compression on TIF files

Posted: 2013-11-10T11:44:13-07:00
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

Re: Problem with compression on TIF files

Posted: 2013-11-10T12:30:00-07:00
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.

Re: Problem with compression on TIF files

Posted: 2013-11-10T12:43:14-07:00
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.

Re: Problem with compression on TIF files

Posted: 2013-11-10T13:21:26-07:00
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.

Re: Problem with compression on TIF files

Posted: 2013-11-10T13:49:19-07:00
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.

Re: Problem with compression on TIF files

Posted: 2013-11-15T11:05:25-07:00
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.

Re: Problem with compression on TIF files

Posted: 2013-11-15T12:00:49-07:00
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?)

Re: Problem with compression on TIF files

Posted: 2014-08-27T03:09:37-07:00
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.

Re: Problem with compression on TIF files

Posted: 2014-09-02T00:28:44-07:00
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.