JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
njdoyle
Posts: 8
Joined: 2014-07-08T12:12:20-07:00
Authentication code: 6789
Location: Ottawa, Ontario

JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post by njdoyle » 2014-10-31T11:09:29-07:00

I'm trying to encode images with JPEG 2000. I'm using "-define jp2:rate=x,x,..." to set quality levels.

This options seems to be ignored by ImageMagick.

I would expect these two commands to produce similar or identical results:

Code: Select all

$ opj_compress -r 50 -i example.png -o example.opj.jp2
$ convert example.png -define jp2:rate=50 example.im.jp2
opj_compress produces JPEG 2000 images with a reasonable amount of compression and a file size I would expect for an image of that compression/quality.
ImageMagick produces what seems to be a losslessly compressed image that has a relatively high file size.

I am using ImageMagick 6.8.9-9 and OpenJPEG 2.1.0.

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

Re: JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post by magick » 2014-10-31T17:47:12-07:00

Set the rate to 115. As the rate gets larger, the higher the compression. Or use something like -quality 25, for example.

njdoyle
Posts: 8
Joined: 2014-07-08T12:12:20-07:00
Authentication code: 6789
Location: Ottawa, Ontario

Re: JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post by njdoyle » 2014-11-03T11:15:31-07:00

magick wrote:Set the rate to 115. As the rate gets larger, the higher the compression. Or use something like -quality 25, for example.
I have used a number of different values for rate, including 115 and higher. The option is entirely ignored and a lossless image is always output.

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

Re: JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post by magick » 2014-11-03T15:37:29-07:00

We're clueless why it fails for you. We're using OpenJPEG 2.1.0 also and as we change the rate, the size of the output image changes as expected.

verve
Posts: 1
Joined: 2016-08-08T12:52:11-07:00
Authentication code: 1151

Re: JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post by verve » 2016-08-08T12:59:43-07:00

This continues to be a bug, even with OpenJPEG 2.1.1, on my Mac OS X box, where I installed imagemagick by installing vips just yesterday with

Code: Select all

brew install vips --with-cfitsio --with-imagemagick --with-openexr --with-openslide --with-webp
as described at http://www.vips.ecs.soton.ac.uk/index.p ... ld_on_OS_X . You can see that http://stackoverflow.com/questions/3067 ... -file-size pretty much describes the same bug. Any new insights into this?

Thanks.

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

Re: JPEG 2000 encoder ignoring "-define jp2:rate=x,x,..."

Post by magick » 2016-08-08T13:27:59-07:00

These commands:
  • convert logo: -define jp2:rate=10 10.jp2
    convert logo: -define jp2:rate=20 20.jp2
    convert logo: -define jp2:rate=40 40.jp2
    convert logo: -define jp2:rate=80 80.jp2
returns these file sizes suggesting compression is being properly applied, the first number is the size in bytes:
  • 92176 Aug 8 16:21 10.jp2
    46093 Aug 8 16:21 20.jp2
    23049 Aug 8 16:21 40.jp2
    11516 Aug 8 16:21 80.jp2
What do you get on your system?

Post Reply