Hello,
I'm doing a OCR project and currently i'm using convert command to convert pdf to jpg.
Due to some reason, i have to use ghostscript now.
From what i see, the image quality from gs is much better.
However, seems OCR has better result from convert command result.
convert result
https://cl.ly/48d7aa1a6ced
gs result
https://cl.ly/eaeb7b32df1e
I wonder what causes this difference. And if i have to use gs now, how could i get similar result as convert?
Commands I use
> convert -quality 100 ~/sample.pdf jpgs/a-%02d.jpg
> gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=1 -dGridFitTT=2 "-sDEVICE=png16m" "-r72x72" -sOutputFile=./jpgs/a-%02d.jpg ~/sample.pdf
Thank you very much
convert and gs results difference
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert and gs results difference
ImageMagick uses Ghostscript to process PDF. The only issue would be what arguments are set in the delegates.xml file for reading PS/PDF/etc.
Re: convert and gs results difference
Thanks. I wonder where the "bold" font come from in convert result.
I used command in delegates.xml for pdf, it outputed ps, not jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert and gs results difference
The two linked images are clearly from different documents, or different parts of the same document, so we don't know why they have different quality. They seem to be rasterized at different densities.
"-verbose" is useful to see what Ghostscript command IM is using.
"-verbose" is useful to see what Ghostscript command IM is using.
snibgo's IM pages: im.snibgo.com
Re: convert and gs results difference
You are correct, they are from different pages in the same pdf.snibgo wrote: ↑2019-10-08T04:42:40-07:00 The two linked images are clearly from different documents, or different parts of the same document, so we don't know why they have different quality. They seem to be rasterized at different densities.
"-verbose" is useful to see what Ghostscript command IM is using.
Here is the log with -verbose
```
convert -verbose sample.pdf a.jpg
'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/var/folders/pb/tbjqx4_56w1cv1htzdm5yh4c0000gn/T/magick-15645ycTMnExb7xla%d' '-f/var/folders/pb/tbjqx4_56w1cv1htzdm5yh4c0000gn/T/magick-156456UMILWLqIH8a' '-f/var/folders/pb/tbjqx4_56w1cv1htzdm5yh4c0000gn/T/magick-15645KqScxlvU4x6G'
/var/folders/pb/tbjqx4_56w1cv1htzdm5yh4c0000gn/T/magick-15645ycTMnExb7xla1 PNG 595x842 595x842+0+0 8-bit sRGB 35364B 0.020u 0:00.011
/var/folders/pb/tbjqx4_56w1cv1htzdm5yh4c0000gn/T/magick-15645ycTMnExb7xla2 PNG 595x842 595x842+0+0 8-bit sRGB 41345B 0.030u 0:00.008
sample.pdf[0] PDF 595x842 595x842+0+0 16-bit sRGB 35364B 0.040u 0:00.008
sample.pdf[1] PDF 595x842 595x842+0+0 16-bit sRGB 41345B 0.010u 0:00.000
sample.pdf=>a-0.jpg[0] PDF 595x842 595x842+0+0 16-bit GrayscaleAlpha Gray 66963B 0.020u 0:00.010
sample.pdf=>a-1.jpg[1] PDF 595x842 595x842+0+0 16-bit GrayscaleAlpha Gray 83686B 0.050u 0:00.021
```
left from gs, right from convert
https://cl.ly/1db1d521d222
Any idea?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert and gs results difference
The resolution seems to be the same (caps height about 7 pixels) but the IM result is monochrome, black and white with no grays, hence the letters are aliased. The command you show "convert -verbose sample.pdf a.jpg" shouldn't remove grays.wwubcn wrote:left from gs, right from convert
Can you link to a sample input PDF?
snibgo's IM pages: im.snibgo.com
Re: convert and gs results difference
I'm very sorry that i could not share the pdf.snibgo wrote: ↑2019-10-08T05:47:27-07:00The resolution seems to be the same (caps height about 7 pixels) but the IM result is monochrome, black and white with no grays, hence the letters are aliased. The command you show "convert -verbose sample.pdf a.jpg" shouldn't remove grays.wwubcn wrote:left from gs, right from convert
Can you link to a sample input PDF?
From gs, now i get png file. Then i use convert on the png to create jpg. The jpg is what I need (bold).
I guess my request is a little strange because i am looking for a 'worse' result
![Very Happy :D](./images/smilies/icon_biggrin.gif)