Page 1 of 1

JP2 compression (changes?)

Posted: 2016-09-09T01:58:03-07:00
by andrixnet
I've been using ImageMagick version 6.8.6-10 (linux) for a while, converting images for a project from JPEG to JP2

Code: Select all

convert INPUT -format jp2 -quality 50 OUTPUT
Experimentation showed that this quality level yielded a good visual quality (very little distortion visible to the eye) while also reducing file size compared to the original JPEGs.

Recently I've installed a windows build on another computer, version 7.0.3 (Win64 static at 16 bits-per-pixel component)

I tried to convert images using

Code: Select all

magick INPUT -format jp2 -quality 50 OUTPUT
, but the result was much larger files.

Original image: Image
Converted image using convert (linux) version 6.8.6-10: 133k
Converted image using magick (windows) version 7.0.3: 701k

What am I doing wrong?

Re: JP2 compression (changes?)

Posted: 2016-09-09T02:15:52-07:00
by andrixnet
Using version 7.0.3:

Code: Select all

magicj img_0369.jpg img_0369.bmp
results in a 5625k file (I'll use this as a reference)

Code: Select all

magick img_0369.jpg -format jp2 -define jp2:rate=16 img_0369_16.jp2
results in a 351k file which is exactly 16:1 compression rate.

Code: Select all

magick img_0369.jpg -format jp2 -quality 75 img_0369_75.jp2
results in a 1684k file which contradicts the documentation here: https://www.imagemagick.org/script/comm ... hp#quality which says clearly that a quality of 75 is a close equivalent to a 16:1 compression rate.

Using version 6.8.6-10:

Code: Select all

convert img_0369.jpg -format jp2 -define jp2:rate=0.0625 img_0369_16_1.jp2
results in a 351k file which is exactly 16:1 compression rate (1/16 = 0.0625)
Note: JP2 options are different then in 7.x
JP2 Encoding Options:
rate=r
Specify the target rate. The argument r is a positive real number.
Since a rate of one corresponds to no compression, one should
never need to explicitly specify a rate greater than one. By
default, the target rate is considered to be infinite.

Code: Select all

 convert img_0369.jpg -format jp2 -quality 75 img_0369_75.jp2
results in a 352k file which is very close to 16:1 compression rate, which is correct.

=======================================================
Is this a bug in ImageMagick 7.0.3, a change in behaviour (I'd say for the worse) or is it an issue with libopenjpeg?

Re: JP2 compression (changes?)

Posted: 2016-09-09T02:19:36-07:00
by andrixnet

Code: Select all

convert -version
Version: ImageMagick 6.8.6-10 2016-05-30 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib cairo djvu fftw fontconfig freetype jng jp2 jpeg lcms lzma openexr pango pangocairo png png rsvg tiff x xml zlib

Code: Select all

magick -version
Version: ImageMagick 7.0.3-0 Q16 x64 2016-09-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib