Why is convert reducing quality when PNG -> PNG

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
freyja
Posts: 6
Joined: 2014-11-13T23:44:24-07:00
Authentication code: 6789

Why is convert reducing quality when PNG -> PNG

Post by freyja »

When I convert PNG to PNG, the quality is reduced (I can see it visually and also OCR output quality is greatly reduced):

Code: Select all

convert Fontanes.png Fontanes.output.png
Here is the input:
http://www.cs.put.poznan.pl/ekowalczuk/Fontanes.png
and result:
http://www.cs.put.poznan.pl/ekowalczuk/ ... output.png

Using

Code: Select all

identify
I see that the types of pictures differ:

Code: Select all

Fontanes.png PNG 825x73 825x73+0+0 8-bit DirectClass 62.9KB 0.000u 0:00.000
Fontanes.output.png[1] PNG 825x73 825x73+0+0 8-bit PseudoClass 256c 37.7KB 0.000u 0:00.000
...
Colorspace: sRGB
Colorspace: Grey
I don't understand why the picture is altered at all.

Of course I don't need to convert PNG to PNG, but I believe this behaviour affects what happens in JMagick code. When I feed bytes extracted in IM the OCR output quality is worse than when feeding it with bytes read for example from ImageIO.

I want to support many different formats, so I cannot use ImageIO for this purpose.

I will appreciate any remarks on this. Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why is convert reducing quality when PNG -> PNG

Post by snibgo »

I think you are using an old version of IM, when it converted grayscale to linear.

What does "convert -version" say? If older than 6.8.8, I suggest you upgrade.
snibgo's IM pages: im.snibgo.com
rich2005
Posts: 32
Joined: 2012-04-09T11:07:36-07:00
Authentication code: 8675308

Re: Why is convert reducing quality when PNG -> PNG

Post by rich2005 »

Not comparing like-with-like

Original is RGB, converted file is greyscale.

Try convert in.png png24:out.png
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Why is convert reducing quality when PNG -> PNG

Post by pipitas »

My version of convert (6.8.9-8 Q16 x86_64 2014-10-03) does not exhibit this problem. I did run:

Code: Select all

convert Fontanes.png Fontanes.output2.png 

compare Fontanes.png Fontanes.output2.png -compose src delta.png
The resulting delta.png does not show a single red pixel.
freyja
Posts: 6
Joined: 2014-11-13T23:44:24-07:00
Authentication code: 6789

Re: Why is convert reducing quality when PNG -> PNG

Post by freyja »

Thank you for such quick answers.

Indeed upgrading the version to 6.8.9-8 helped for console case, but it caused JMagick to behave strangely (MagickImage constructor using byte[] returns 0-size image and blobToImage method hangs).

It might be so that IM and JMagick versions have to match exactly.
The newest JMagick I could found was 6.7.7 (complied from repository).
I will try to ask on JMagick mailing list about it.

Update:
JMagick developer confirmed that versions of IM and JMagick have to match exactly. If they match I don't get an empty picture when using the constructor, but a proper one. Method blobToImage hangs indifferently in both IM version, but I don't need it when constructor works.
Post Reply