Page 1 of 1
Not converting pdf image to png correctly
Posted: 2017-11-08T12:20:21-07:00
by troyd1
windows 7 64 bit
Version: ImageMagick 7.0.7-10 Q16 x64 2017-11-05
GS: 9.22 X64
When I do a "convert 00000B26,pdf 00000B26-IM.png" it truncates the image.
I did an export with gimp and it game me a correct image. Any suggestions?
I just installed the latest version of IM and GS.
The files are here:
https://drive.google.com/drive/folders/ ... 2Nmek9sNGM
Re: Not converting pdf image to png correctly
Posted: 2017-11-08T13:05:51-07:00
by fmw42
With IM 7 you should use magick, not convert. Your command works fine for me on IM 7.0.7.10 Q16 Mac OSX with GS 9.21, but your image has an alpha channel. Using identify the alpha channel shows min (white) and max (black), which is backwards. Using magick identify, I get the proper values. What is happening is that your alpha channel is blanking out the rest of the image. So you need to turn it off or flatten it against white. Using a larger density will give a bigger image, but higher quality. You can also resize reading the PDF (by 25%) to get back to default size. (default density is 72. so 72*4=288 thus 25 % reduction).
But a better conversion could be had with
Code: Select all
magick -density 288 00000B26.pdf -background white -flatten 00000B26.png
Re: Not converting pdf image to png correctly
Posted: 2017-11-09T07:35:27-07:00
by troyd1
I am doing more things, but just pared down my command to show a simple example of it not working. I tried the magick command and am getting the same result as the convert. Just the header and nothing more. I added the -background white and -flatten and it gave me a full page, it still gave me the header, but the rest is still missing. Can you provide the code that you used that worked? I tried the command that you suggested: magick -density 288 00000B26.pdf -background white -flatten 00000B26.png and it did the same thing. I put the image created on the link and called it 00000B26x.png.
Re: Not converting pdf image to png correctly
Posted: 2017-11-09T10:48:23-07:00
by fmw42
This works for me on IM 7.0.7.10 Q16 Mac OSX and GS 9.21
Code: Select all
magick -density 325 00000B26.pdf -resize 25% -background white -flatten 00000B26.png
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T06:32:36-07:00
by troyd1
Do you think it could be just the 1 version difference in ghostscript?
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T13:06:13-07:00
by fmw42
I suppose it is possible. Also check your delegates.xml file.
Unix:
/usr/local/etc/ImageMagick-6/delegates.xml
Does your line:
<delegate decode="
ps:alpha" stealth="True" command=""gs" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "
-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
show sDEVICE=pngalpha or pnmraw?
If not pngalpha, then change it to pngalpha
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T13:46:08-07:00
by troyd1
I am on windows. Where would it be?
Also, I believe it worked for you, just trying to figure out why it is not working for me.
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T13:54:06-07:00
by fmw42
Sorry, I do not use Windows and don't know the file structure there. Perhaps one of the Windows users will see this shortly and can answer that better. Do you know whether ImageMagick can find Ghostscript? Probably not the issue since you did not get an error message about that.
But just to be sure, if you do
Does the line starting with DELEGATES show gs or gslib?
DELEGATES bzlib mpeg fftw fontconfig freetype
gslib jbig jng jpeg lcms lqr lzma openexr openjp2 png ps rsvg tiff webp x xml zlib
Not sure if it shows on Windows systems or not.
Can you backdown your Ghostscript version and see if that works?
Or try converting your PDF using Ghostscript standalone?
Do you have OpenMP or OpenCL configured? You could try recompiling without them. Or set the threads to 1 to see if that helps. See
viewtopic.php?f=2&t=20756&p=83407&hilit=thread#p83407
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T14:27:26-07:00
by snibgo
On Windows, delegates.xml is usually in the same directory as convert.exe.
When I try to open the PDF with Adobe Reader, I get a message: "A font package is required to correctly display this page." If I don't download these fonts, Adobe Reader shows only the header, and IM convert creates just the header. "Document properties" says the font is "MSung-Light".
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T15:30:39-07:00
by fmw42
Did you install all the Ghostscript fonts? See the links to them at
http://www.imagemagick.org/download/delegates/
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T15:55:25-07:00
by snibgo
Who, me? No, I haven't installed more fonts for Ghostscript than comes in the standard package. And this might be the OP's problem, that the PDF uses a non-standard font that isn't embedded in the PDF. Installing extra fonts may cure the problem.
In any case, if Adobe Reader can't rasterise a PDF, there is little chance of Ghostscript doing any better.
Re: Not converting pdf image to png correctly
Posted: 2017-11-10T18:19:02-07:00
by fmw42
Re: Not converting pdf image to png correctly
Posted: 2017-11-13T06:44:54-07:00
by snibgo
When reading a PDF makes "a low definition and low size" output, this is usually because the density setting is too low. Try "-density 300" or some other number before the pdf, eg:
Code: Select all
magick -density 300 in.pdf out.png
Re: Not converting pdf image to png correctly
Posted: 2017-11-13T10:03:33-07:00
by troyd1
Sorry I did not reply sooner, was out. Here is my:
c:\>convert -list configure
Path: [built-in]
Name Value
-------------------------------------------------------------------------------
FEATURES OpenMP
NAME ImageMagick
QuantumDepth 16
Path: C:\Program Files\ImageMagick-7.0.7-Q16\configure.xml
Name Value
-------------------------------------------------------------------------------
CC vs10
COPYRIGHT Copyright (C) 1999-2017 ImageMagick Studio LLC
DELEGATES bzlib freetype jpeg jp2 lcms png raw tiff x11 xml wmf zlib
FEATURES OpenMP
HOST Windows
LIB_VERSION 0x707
LIB_VERSION_NUMBER 7,0,7,10
NAME ImageMagick
RELEASE_DATE 2017-12-21
VERSION 7.0.7
WEBSITE
http://www.imagemagick.org
I do not see and GS. How do I add that in windows?
Re: Not converting pdf image to png correctly
Posted: 2017-11-13T10:10:31-07:00
by snibgo
troyd1 wrote:I do not see and GS. How do I add that in windows?
Why do you want to? IM is successfully running GS.
I suspect the problem is a missing font. Can Adobe Reader read your PDF?