Page 1 of 1

Black and white PDF to color tiff

Posted: 2014-10-14T13:48:38-07:00
by rexmism
Hello,
I'm converting some pdfs (some color, some black and white) to tiffs which would retain any color. These tiffs are then imported into our document imaging system (Image Now). However, I'm noticing that even though black and white pdfs convert to tiffs which look just fine, those documents don't show up properly in the document imaging system. They either have horizontal lines all the way down them or it gives an error that the file is of an invalid type. I've also noticed that the photometric interpretation tag for tiff files that work is RGB, and blank for those that don't. I'm not sure if this is the cause of the problem or just a symptom. But I think ImageMagick is just converting my black and white pdfs to tiffs with some kind of black and white tag (even with a color command) and something isn't meshing right. The command I'm using to convert to color tiffs is:
convert -density 150 -compress lzw -depth 8
Incidentally, all the tiffs work fine when converted with a gray-scale command. Does anyone have any ideas of a command that will convert all the pdfs to color tiffs? Or if not, some way that my script can tell if the converted tiff is in black and white and can convert it again with the gray scale command?
Thanks!
Matt

Re: Black and white PDF to color tiff

Posted: 2014-10-14T14:34:03-07:00
by fmw42
What version of IM and platform are you using? There could be a bug in your version. Many organizations do not follow the Tiff standards, so there could be issues due to that.

You would be best to upload an example file to some place like dropbox.com (both input and output), so others can test. Put the URLs here so we can download.

convert -density 150 -compress lzw -depth 8
This is not a complete command. Were did you put the input and output images? Often people do not follow the IM 6 proper syntax and that can cause problems. see http://www.imagemagick.org/Usage/basics/#cmdline. Vector image formats like pdf would be slightly different as the density must come before the input.

Have you tried another compression type to see if that is the problem?

Re: Black and white PDF to color tiff

Posted: 2014-10-14T21:28:36-07:00
by rexmism
Thanks for your reply. In the change log, the first version listed at the top is 6.7.4-10, so I'm guessing that's the version. We downloaded it within the last few weeks. The platform is Windows XP. Here's the full command:

FOR %%I IN (*TRAN*.pdf) DO ImageMagik\convert -density 150 -compress lzw -depth 8 "%%~nxI" "%%~nI@%%02d.tif"

The pdfs are high school transcripts, so I can't post them, but the problem seems to occur with any pdf that is only black and white. There seems to be some kind of mismatch going on, but I'm not sure what. If anyone has a solid example command of pdf to tiff in color (at a reasonable file size), I would love to see and try it. Please let me know if you have any more questions. Thanks so much.

Re: Black and white PDF to color tiff

Posted: 2014-10-14T21:39:37-07:00
by fmw42
6.7.4-10 is ancient. IM is at 6.8.8.8 so about 140 versions old. That is likely the problem. There is either different behavior (viewtopic.php?f=4&t=21269) or a bug in that version. Much has changed. You should upgrade. See http://www.imagemagick.org/script/binar ... hp#windows or http://www.imagemagick.org/script/insta ... hp#windows

Re: Black and white PDF to color tiff

Posted: 2014-10-16T13:47:50-07:00
by rexmism
Thanks for the link. I've install the new version of ImageMagick and am converting with it now, but I still seem to be having the same issue. Any other thoughts?

Re: Black and white PDF to color tiff

Posted: 2014-10-16T15:17:14-07:00
by snibgo
Put a sample PDF that causes this problem somewhere like dropbox.com and paste the URL here.

Have you also upgraded Ghostscript?

Re: Black and white PDF to color tiff

Posted: 2014-10-22T10:40:24-07:00
by rexmism
Sorry for the delay in my reply. Since I can't post the real documents, I tried just creating a PDF from a Word file. It gets the error just like the real documents. I'm putting links to both the PDF and the tif created.

PDF: https://www.dropbox.com/s/vcqoh56eyul6j ... 1.pdf?dl=0
TIF: https://www.dropbox.com/s/ejf7w9nfeotie ... 0.tif?dl=0

Re: Black and white PDF to color tiff

Posted: 2014-10-22T11:08:25-07:00
by snibgo
To get 3 color channels in the TIFF, use "-type truecolor", eg:

Code: Select all

convert -density 150 1048662@COTRAN_1.pdf -background white -flatten -type truecolor -compress lzw x.tiff
This also flattens against white. If you want a transparent background, omit "-background white -flatten".

I don't know if this will cure the problem you have.

Re: Black and white PDF to color tiff

Posted: 2014-10-22T13:11:34-07:00
by rexmism
Really nice try - when I use that command, the photometric interpretation tag is RGB, so I really thought it would work, but I still get the error. I guess I'll blame it on Image Now and try a different approach to this. Thanks for your help!

Re: Black and white PDF to color tiff

Posted: 2014-10-22T13:27:00-07:00
by snibgo
Sorry that didn't help. Maybe one or more of the TIFF defines will do the trick. See http://www.imagemagick.org/script/comma ... php#define