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
text goes missing when converting pdf to jpg
-
- 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
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?
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
Re: text goes missing when converting pdf to jpg
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
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
-
- 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
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:
from both command line and PHP. This will tell you if multiple versions are being used.
I'm not a GS, PHP or Unix guru, but I would start with:
Code: Select all
convert success.pdf -debug all success.jpg
snibgo's IM pages: im.snibgo.com
Re: text goes missing when converting pdf to jpg
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.
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.
Re: text goes missing when converting pdf to jpg
I solve a similar problem with missing text when calling convert from MATLAB by adding the following to the call:
i.e.
I think the problem is related to the version of Ghostscript installed on my system: 9.05 (2012-02-08).
Code: Select all
export LD_LIBRARY_PATH="";
Code: Select all
$command = "export LD_LIBRARY_PATH=\"\";/usr/bin/convert $source $dest"