Converting PDF to PNG Issue

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
sgreene
Posts: 3
Joined: 2018-08-23T17:59:26-07:00
Authentication code: 1152

Converting PDF to PNG Issue

Post by sgreene »

Hi Everyone,

I am having an issue while converting a PDF to a thumbnail PNG image, either the text doesn't display or is garbled up... Hope someone can help I can't determine any other possible ways to fix the issue.

Here is what the PDF looks like:
Image

This is the result of the conversion:
Image

Command I am using is:
convert -colorspace RGB Abcs.pdf[0] -colorspace sRGB -resize '25%' -quality 100 test.png

Software Versions I am using
ImageMagick 6.9.7-4 Q16 x86_64 20170114
GPL Ghostscript 9.22 (2017-10-04)
Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-32-generic x86_64)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting PDF to PNG Issue

Post by fmw42 »

Please post the actual pdf to some free hosting service that won't change it or zip it first before posting. Then put the URL to the PDF or zip file here.

You seem to convert to linear RGB when reading the PDF rather than nonlinear sRGB. Then you change it to non-linear. That could be an issue.

Try just reading it in as sRGB.

Code: Select all

convert -colorspace sRGB Abcs.pdf[0] -resize '25%' -quality 100 test.png
sgreene
Posts: 3
Joined: 2018-08-23T17:59:26-07:00
Authentication code: 1152

Re: Converting PDF to PNG Issue

Post by sgreene »

fmw42 wrote: 2018-08-23T18:37:32-07:00 Please post the actual pdf to some free hosting service that won't change it or zip it first before posting. Then put the URL to the PDF or zip file here.

You seem to convert to linear RGB when reading the PDF rather than nonlinear sRGB. Then you change it to non-linear. That could be an issue.

Try just reading it in as sRGB.

Code: Select all

convert -colorspace sRGB Abcs.pdf[0] -resize '25%' -quality 100 test.png
thanks for the quick response i did try your suggested command but got the same results. here is the full pdf file.
Last edited by sgreene on 2018-08-26T06:31:24-07:00, edited 1 time in total.
ifkey
Posts: 8
Joined: 2018-08-23T11:50:07-07:00
Authentication code: 1152

Re: Converting PDF to PNG Issue

Post by ifkey »

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

Re: Converting PDF to PNG Issue

Post by fmw42 »

This works fine for me using ImageMagick 6.9.10.10 Q16 Mac OSX with ghostscript 9.21 and libpng 1.6.34

Code: Select all

convert -colorspace sRGB -density 288 abcsousr.pdf[0] -resize 25% result.png
If this does not work, then upgrade ghostscript (as I have heard there were issues with 9.22) and also upgrade libpng, if needed.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PDF to PNG Issue

Post by snibgo »

It also works fine for me, IM 7.0.7-28 and Ghostscript v9.19.
snibgo's IM pages: im.snibgo.com
sgreene
Posts: 3
Joined: 2018-08-23T17:59:26-07:00
Authentication code: 1152

Re: Converting PDF to PNG Issue

Post by sgreene »

Thank you everyone, I have manually upgraded to 9.23 (what a pain) and it's working great now. I was using apt-get to install and it only has 9.22 as latest version.
Post Reply