'convert' produces bad quality since update to Ubuntu 12.04

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
Mountain_Geek
Posts: 6
Joined: 2012-04-17T04:05:25-07:00
Authentication code: 8675308

'convert' produces bad quality since update to Ubuntu 12.04

Post by Mountain_Geek »

I have recently updated from Ubuntu 11.10 to Ubuntu 12.04. Since then, a 'convert' script which I have used for years suddenly started producing worse quality (jagged edges, no dithering anymore?).

Here's the script:
convert -density 150 '/path/file.pdf' -colorspace Gray -strip -quality 85 '/path/file.jpg'

Here's how the resulting jpg used to look before:
Image

And here's how it looks now:
Image

Version: ImageMagick 6.6.9-7

Any ideas?

Thanks in advance!
Last edited by Mountain_Geek on 2012-04-17T08:08:05-07:00, edited 1 time in total.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by glennrp »

Your images aren't visible (just the word "Image" appears in your message).
Can you post them (along with the pdf) on a web page somewhere?

Were you using the same ImageMagick version before? If so the difference
is probably in your PDF decoder or possibly in the JPEG encoder.

What happens if you convert to a lossless format such as PPM? If it
looks the same, that would say the JPEG encoder isn't to blame.
Mountain_Geek
Posts: 6
Joined: 2012-04-17T04:05:25-07:00
Authentication code: 8675308

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by Mountain_Geek »

Thx for your reply:
glennrp wrote:Your images aren't visible (just the word "Image" appears in your message).
Can you post them (along with the pdf) on a web page somewhere?
OK, the jpgs should be visible now. Posting the pdf file is useless: it happens with all pdf files regardless of the source.

glennrp wrote:Were you using the same ImageMagick version before? If so the difference
is probably in your PDF decoder or possibly in the JPEG encoder.
Good question: might be that the new Ubuntu release has automatically updated the ImageMagick version as well.

glennrp wrote:What happens if you convert to a lossless format such as PPM? If it
looks the same, that would say the JPEG encoder isn't to blame.
The ppms look crappy, too.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by NicolasRobidoux »

By "updated", do you mean that you did not do a clean reinstall? Despite the best intentions of the the Ubuntu devs, me and my grad students have not found this to be a 100% pain-free way of moving to a more recent version of Ubuntu. (No clue if this applies to 12.04 from, I hope, a fully updated 11.10. We're still with Ubuntu 11.10/Mint 12.)

ImageMagick has a particular long and complex list of delegate libraries. For this reason, it, of all things, is likely to break when updating instead of doing a full install when changing major version of any OS.

I am far from sure that this is what's going on. But I figured you should know.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by magick »

Add -flatten to your command line:
  • convert -density 150 -colorspace gray '/path/file.pdf' -flatten -quality 85 '/path/file.jpg'
or even better:
  • convert -density 600 -colorspace gray '/path/file.pdf' -flatten -resize 25% -quality 92 '/path/file.jpg'
Mountain_Geek
Posts: 6
Joined: 2012-04-17T04:05:25-07:00
Authentication code: 8675308

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by Mountain_Geek »

convert -density 150 -colorspace gray '/path/file.pdf' -flatten -quality 85 '/path/file.jpg'
Thanks: The "flatten" parameter somehow drastically improves the quality of text on white background (which was the major issue)!

The second suggestion produces even better quality, however the decoding at higher resolution and then resizing takes quite a while and it is not really worth the extra time and file space...

BUT: I usually convert a number of pdf files at the same time and the expected result are separate jpg files. The "flatten" parameter, however, layers them all onto a single page! Is there a way around that?

Cheers!
Last edited by Mountain_Geek on 2012-04-25T01:43:28-07:00, edited 1 time in total.
Mountain_Geek
Posts: 6
Joined: 2012-04-17T04:05:25-07:00
Authentication code: 8675308

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by Mountain_Geek »

NicolasRobidoux wrote:By "updated", do you mean that you did not do a clean reinstall? Despite the best intentions of the the Ubuntu devs, me and my grad students have not found this to be a 100% pain-free way of moving to a more recent version of Ubuntu. (No clue if this applies to 12.04 from, I hope, a fully updated 11.10. We're still with Ubuntu 11.10/Mint 12.)

ImageMagick has a particular long and complex list of delegate libraries. For this reason, it, of all things, is likely to break when updating instead of doing a full install when changing major version of any OS.

I am far from sure that this is what's going on. But I figured you should know.
You are only too right, but every approach has its downturns. A clean install involves about as much work getting back to where you were before (in terms of all the little tweaks that accumulate over the years) as an update requires patching around...
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by NicolasRobidoux »

With text, use PNG. With pngcrush if you want to squeeze out every little bit. Make sure you get a PNG8 out of this, and strip.
JPEG is very ill-suited for text.
Mountain_Geek
Posts: 6
Joined: 2012-04-17T04:05:25-07:00
Authentication code: 8675308

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by Mountain_Geek »

NicolasRobidoux wrote:With text, use PNG. With pngcrush if you want to squeeze out every little bit. Make sure you get a PNG8 out of this, and strip.
JPEG is very ill-suited for text.
The converted files are subsequently used in an accounting software which can handle jpgs only...
Mountain_Geek
Posts: 6
Joined: 2012-04-17T04:05:25-07:00
Authentication code: 8675308

Re: 'convert' produces bad quality since update to Ubuntu 12

Post by Mountain_Geek »

OK, I have finally figured out what helps: I have added -bordercolor white -border 0 -alpha off to the command line and there we go: fine result!
Post Reply