convert pdf to monochrome png results in mostly black document

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
warpno
Posts: 5
Joined: 2017-09-01T09:41:27-07:00
Authentication code: 1151

convert pdf to monochrome png results in mostly black document

Post by warpno » 2017-09-18T05:34:35-07:00

Hi all,

trying to convert a pdlatex generated two-pages pdf form (white background, black text, headers with grey background) into a monochrome png always results in the first png (i.e. corresponding to the first page of the pdf) being almost completely black. This happens regardless of what threshold value I set, e.g.:

Code: Select all

convert test.pdf -monochrome -threshold 50% test.png
Thanks for any help

snibgo
Posts: 9383
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert pdf to monochrome png results in mostly black document

Post by snibgo » 2017-09-18T05:59:15-07:00

After "-monochrome", the image contains black and white only, so "-threshold" has no effect. If you want to threshold at a certain level, just do that, without "-monochrome" (or reverse the order: threshold first, then monochrome).
snibgo's IM pages: im.snibgo.com

warpno
Posts: 5
Joined: 2017-09-01T09:41:27-07:00
Authentication code: 1151

Re: convert pdf to monochrome png results in mostly black document

Post by warpno » 2017-09-18T06:05:35-07:00

Thank you very much snibgo,

now I have another problem: I need a real monochrome tiff but when I do identify I get:

Code: Select all

TIFF 595x842 595x842+0+0 8-bit Grayscale Gray 15426B 0.000u 0:00.000
shouldn't it be: "Gray 2c"??

snibgo
Posts: 9383
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert pdf to monochrome png results in mostly black document

Post by snibgo » 2017-09-18T06:42:44-07:00

Sorry, I don't know what "a real monochrome tiff" is. Perhaps one of the "-type" options gives you that, eg "-type palette".

IM tools don't tell you how the image is stored in the file. If you want to know that, use exiftool.
snibgo's IM pages: im.snibgo.com

warpno
Posts: 5
Joined: 2017-09-01T09:41:27-07:00
Authentication code: 1151

Re: convert pdf to monochrome png results in mostly black document

Post by warpno » 2017-09-18T06:44:10-07:00

I solved it.
For some reason I had to set:

Code: Select all

-compress Group4

Post Reply