Black and white PDF to color tiff

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
rexmism
Posts: 8
Joined: 2014-10-14T13:33:51-07:00
Authentication code: 6789

Black and white PDF to color tiff

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Black and white PDF to color tiff

Post 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?
rexmism
Posts: 8
Joined: 2014-10-14T13:33:51-07:00
Authentication code: 6789

Re: Black and white PDF to color tiff

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Black and white PDF to color tiff

Post 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
rexmism
Posts: 8
Joined: 2014-10-14T13:33:51-07:00
Authentication code: 6789

Re: Black and white PDF to color tiff

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Black and white PDF to color tiff

Post by snibgo »

Put a sample PDF that causes this problem somewhere like dropbox.com and paste the URL here.

Have you also upgraded Ghostscript?
snibgo's IM pages: im.snibgo.com
rexmism
Posts: 8
Joined: 2014-10-14T13:33:51-07:00
Authentication code: 6789

Re: Black and white PDF to color tiff

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Black and white PDF to color tiff

Post 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.
snibgo's IM pages: im.snibgo.com
rexmism
Posts: 8
Joined: 2014-10-14T13:33:51-07:00
Authentication code: 6789

Re: Black and white PDF to color tiff

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Black and white PDF to color tiff

Post 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
snibgo's IM pages: im.snibgo.com
Post Reply