text goes missing when converting pdf to jpg

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
phy9pas

text goes missing when converting pdf to jpg

Post by phy9pas »

Hello,

I'm trying to convert pdfs to jpg for thumbnailing.

I'm using IM Version 6.6.2-4
I've just updated ghostscript to 8.71, whoch solved my previous problem with trying to use new format pdfs.

Now I'm finidng that some of the embedded text goes missing when it is converted.

Here is an example of the source file:
http://www.previewyoursite.co.uk/xbtest/success.pdf

and desticnation file:
http://www.previewyoursite.co.uk/xbtest/success.jpg

I'm using a PHP command line call:

/usr/bin/convert -quality 100 "$source"[0] -thumbnail '{$w}x{$h}' "$dest"

but even if I try a basic call like
/usr/bin/convert $source $dest

I get the same results.

Does anyone have any ideas?

Thanks

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

Re: text goes missing when converting pdf to jpg

Post by snibgo »

With IM 6.6.0 and 6.6.1 under Windows7, I get all the text.

Try running your command from the command line, not under PHP, which may not be picking up the right IM or GS. Still got the problem?
snibgo's IM pages: im.snibgo.com
phy9pas

Re: text goes missing when converting pdf to jpg

Post by phy9pas »

You're right, I tried it from the command line and it worked correctly.
however, I then tried the call directly to GS but from PHP
i.e.
$command = "/usr/local/bin/gs -sDEVICE=jpeg -sOutputFile=$dest $source";
$response = passthru($command);

And that rendered the fonts correctly. Which suggests it's to do with the way IM is configured?

I know that IM needs to point to the gs fonts directorry, but I wouldn't have thought that would affect this as it's using fonts that are embedded in the pdf?
Do you think this might be where the problem lies?

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

Re: text goes missing when converting pdf to jpg

Post by snibgo »

I would suspect PHP versus command line are calling different versions of IM, or GS, or both. (Perhaps it is a fonts problem, but I would eliminate a multiple-version problem first.)

I'm not a GS, PHP or Unix guru, but I would start with:

Code: Select all

convert success.pdf -debug all success.jpg
from both command line and PHP. This will tell you if multiple versions are being used.
snibgo's IM pages: im.snibgo.com
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: text goes missing when converting pdf to jpg

Post by Drarakel »

If you have checked the possibility of multiple IM/GS versions and you still suspect the fonts, then maybe the IM call with PHP doesn't honor all of your path variables or something like that?
This thread could be useful then:
viewtopic.php?t=15520
ImageMagick is using the "-dPARANOIDSAFER" parameter when calling Ghostscript. (I think, "-dPARANOIDSAFER" is deprecated and is the same as "-dSAFER" now.) This way, reading from files is prohibited - apart from the commandline files and the files within your paths. It's a wild guess, but maybe this is the reason why a Ghostscript call within PHP (without "-dPARANOIDSAFER") is successful while the ImageMagick call is not. If so, then you might try to 'fix' the various paths that GS needs in safe mode. Or you could try to delete the "-dPARANOIDSAFER" parameters from your IM delegates.xml (or replace it with "-dNOSAFER"). The latter could lead to a security risk.
See more in the Ghostscript documentation.
ulrik
Posts: 1
Joined: 2014-12-04T09:55:26-07:00
Authentication code: 6789

Re: text goes missing when converting pdf to jpg

Post by ulrik »

I solve a similar problem with missing text when calling convert from MATLAB by adding the following to the call:

Code: Select all

export LD_LIBRARY_PATH="";
i.e.

Code: Select all

$command = "export LD_LIBRARY_PATH=\"\";/usr/bin/convert $source $dest"
I think the problem is related to the version of Ghostscript installed on my system: 9.05 (2012-02-08).
Post Reply