Hi, I'm new here so please go easy on me.
The company I work for uses ImageMagick to convert PDF files to JPG in their application. It is executed on the command line from a PHP script and is run on Linux.
The command we use is:
convert -density 200 -quality 100 <filename>.pdf -unsharpen 0x3.2 -quality 100 <filename>.jpg
convert -version reports:
$ convert -version
Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
The result I get is a blank image (completely white). The PDF file that is the source is a scan of a scan of a scan of a sheet of paper with text on it, so the quality isnt great to begin with. If I try a different PDF file, it works as expected, but this one gives a blank file every time. The server I'm testing this on is running CentOS6.
I dont know if more information is needed, please let me know if I need to provide more.
Issues with unsharp
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issues with unsharp
There is no unsharpen command. It would either be -sharpen or -unsharp. You also have two -quality commands. The first should not be needed. Other than that your command should work if your pdf is not corrupted in some way and you have jpg delegate library and ghostscript libraries installed.convert -density 200 -quality 100 <filename>.pdf -unsharpen 0x3.2 -quality 100 <filename>.jpg
convert -list configure
What does the line starting with DELEGATES say? Does it include jpg and gs?
The other possible issue would be if the pdf was in cmyk format. Then you would need to add -colorspace sRGB before the <filename>.pdf
Re: Issues with unsharp
Thank you fmw42!
I mistyped the convert command, it was "-unsharp" and not "-unsharpen". Both of the libraries are there and in the delegate row.
I did get this working. The -colorspace sRGB fixed the issue and it did convert! Would there be any issue with always using that in the case of converting text-only PDFs?
Thank you again!
I mistyped the convert command, it was "-unsharp" and not "-unsharpen". Both of the libraries are there and in the delegate row.
I did get this working. The -colorspace sRGB fixed the issue and it did convert! Would there be any issue with always using that in the case of converting text-only PDFs?
Thank you again!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issues with unsharp
I am not an expert on that. But I suspect not. Though you could always check the colorspace and use a switch to process it. See string formats for %[colorspace]
On unix:
colorspace=`identify -format "%[colorspace]" yourimage`
if [ $colorspace = "CMYK" ]; then
cspace="-colorspace sRGB"
else
cspace=""
fi
convert ... $cspace yourimage.pdf ... yourimage.jpg
Note that before IM 6.7.5.5 you would want to use -colorspace RGB. After that RGB and sRGB colorspace commands were swapped so as to be correct nomenclature.
On unix:
colorspace=`identify -format "%[colorspace]" yourimage`
if [ $colorspace = "CMYK" ]; then
cspace="-colorspace sRGB"
else
cspace=""
fi
convert ... $cspace yourimage.pdf ... yourimage.jpg
Note that before IM 6.7.5.5 you would want to use -colorspace RGB. After that RGB and sRGB colorspace commands were swapped so as to be correct nomenclature.