Paid: Fix issue converting PDF to JPG #2

Do you need consulting from ImageMagick experts and are willing to pay for their expertise? Or are you well versed in ImageMagick and offer paid consulting? If so, post here otherwise post elsewhere for free assistance.
Post Reply
alex123456
Posts: 8
Joined: 2019-09-20T08:39:58-07:00
Authentication code: 1152

Paid: Fix issue converting PDF to JPG #2

Post by alex123456 » 2019-11-27T15:05:56-07:00

Hi,
I posted a question a few weeks ago that mostly fixed and issue, but has now caused another one.
The original post is with the subject "Paid: Fix issue converting PDF to JPG".
The new issue is that the converted png file has lines which are too 'heavy'.
Here is a screenshot of the original PDF:

Image

Here is a screenshot of the generated .png file:

Image

The issue is that the converted lines are much thicker/heavier.

Here is the command line:
/usr/bin/convert -colorspace sRGB -strokewidth 1 -density 300 +antialias -verbose $PDFFILEPATH -background white -alpha background -alpha off $PNGFILEPATH

I've tried various settings for the strokewidth option, but it doesn't seem to change anything.
The only thing that seems to help is that increasing the desnity to 1200 does make the lines thinner. However, the file sizes are much bigger and the convert operation takes a lot of memory and a long time.

Before I did the version upgrade as suggested in the previous issue, there was never an problem with this. The original PDF line widths were very similar to the generated line width in the new .png file.

This is on CentOS7. Here are the versions rpm:
ImageMagick-6.7.8.9-18.el7.x86_64
ghostscript-9.25-2.el7_7.2.x86_64

convert -version gives:
Version: ImageMagick 6.7.8-9 2019-08-08 Q16 http://www.imagemagick.org

The original PDF is here:
http://demo.builderlynx.com/cc/temp/NG4 ... -4_REV.pdf

I'd be happy to pay to get this issue resolved.

Thanks
Alex.

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Paid: Fix issue converting PDF to JPG #2

Post by fmw42 » 2019-11-27T16:03:50-07:00

Perhaps you do not have the Ghostscript font that corresponds to the font you used in the file on your system. I doubt that -strokewidth and +antialias will do anything in your command. They are only used as far as I know when creating/drawing new text.

However, this command on IM 6.9.10.75 Q16 Mac OSX with GS 9.25 and libpng 1.6.36 works just fine for me.

Code: Select all

convert -density 288 -colorspace sRGB "NG40-1001-C2-4_REV.pdf[0]" -background white -alpha background -alpha off -resize 25% x.png
I would point out that often Linux distributions only patch for security bugs and major updates and not often for all bugs. So your version of Imagemagick could be buggy. However, Imagemagick offloads rendering of PDF to Ghostscript.

What is your version of libpng? If old, try upgrading.

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

Re: Paid: Fix issue converting PDF to JPG #2

Post by snibgo » 2019-11-27T16:13:26-07:00

The trick is to rasterize at whatever density gives the detail you want ("-density" before reading the PDF), then resize down to whatever size you want ("-resize" after reading the PDF). For example:

Code: Select all

magick -density 600 NG40-1001-C2-4_REV.pdf[0] +write x0.png -resize 25% out.png
snibgo's IM pages: im.snibgo.com

alex123456
Posts: 8
Joined: 2019-09-20T08:39:58-07:00
Authentication code: 1152

Re: Paid: Fix issue converting PDF to JPG #2

Post by alex123456 » 2019-11-28T14:21:37-07:00

Replying to fmw42:
Are you able to upload the .png output that you generated. I'd like to see that file.

More generally, just to be clear, the issue is not with the fonts. It is that the brick and other patterns on the home have lines that are much thicker/heavier in the generated .png than in the original .pdf file.

On CentOS7, I have upgraded version:
ImageMagick: ImageMagick-7.0.9-6.x86_64
Ghostscript: ghostscript-9.25-2.el7_7.2.x86_64
These are about the most up to date versions I can find.

Any other suggestions are appreciated.
Thanks
Alex.

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Paid: Fix issue converting PDF to JPG #2

Post by fmw42 » 2019-11-28T19:07:26-07:00

Using Imagemagick 7.0.9.6 Q16 Mac OSX Sierra and GS 9.25, I get the following.

Code: Select all

magick -density 288 -colorspace sRGB "NG40-1001-C2-4_REV.pdf[0]" -background white -alpha background -alpha off -resize 25% NG40-1001-C2-4_REV.png
Image

I also note that the drawing itself is a bit darker than in your PDF. But Imagemagick offloads processing to Ghostscript. So if you have an issue, I suggest you try GS 5.0 or write to the Ghostscript forum/developers.

alex123456
Posts: 8
Joined: 2019-09-20T08:39:58-07:00
Authentication code: 1152

Re: Paid: Fix issue converting PDF to JPG #2

Post by alex123456 » 2019-11-29T07:42:52-07:00

Thanks for the sample. Your generated image has the same darkness that mine does. This is exactly what I'm trying to get rid of. In the original PDF file the lines in the patterning are not as thick. The previous older versions of ImageMagick + Ghostscript had this working better, but they also had other issue that were resolved by upgrading.

I'll do some digging on the ghostscript side.

Thanks.

User avatar
magick
Site Admin
Posts: 11098
Joined: 2003-05-31T11:32:55-07:00

Re: Paid: Fix issue converting PDF to JPG #2

Post by magick » 2019-11-29T09:39:03-07:00

Edit delegates.xml and change `pngalpha` to `png16m`. That should resolve your problem.

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Paid: Fix issue converting PDF to JPG #2

Post by fmw42 » 2019-11-29T09:53:31-07:00

@magick - can you explain the reason and why png16m is better?

User avatar
magick
Site Admin
Posts: 11098
Joined: 2003-05-31T11:32:55-07:00

Re: Paid: Fix issue converting PDF to JPG #2

Post by magick » 2019-11-29T11:05:40-07:00

Perhaps this is a better solution:

Code: Select all

magick -density 288 -colorspace sRGB "NG40-1001-C2-4_REV.pdf[4]" -alpha remove -resize 25% NG40-1001-C2-4_REV.png

Post Reply