Convert jpeg to jpeg 2000 (.jpg to .jp2)

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
Kermit
Posts: 1
Joined: 2014-06-07T08:50:48-07:00
Authentication code: 6789

Convert jpeg to jpeg 2000 (.jpg to .jp2)

Post by Kermit »

Hello,

I like to convert some jpg-files to jpeg2000-files with imagemagick. This German tutorial/explanation shows how to do with imagemagick: http://www.uplawski.eu/france/Cevennen/cev_jp2.html
Nearly all jp2-files created by the author are just a fourth of the original jpg-filesize!

My smartphone takes jpg-pictures with a quality of 88%: identify -verbose picture.jpg => Compression: JPEG Quality: 88

If I try "convert picture.jpg -quality 88 picture.jp2" the created picture.jp2 is much bigger than the original picture.jpg (more than twice as big as the original one!)

I'm helpless, what I did wrong? I like to create smaller pdf with jpeg 2000 images. I'm using img2pdf that works great: https://github.com/josch/img2pdf

Maybe somebody has already wrote a small script, that reads the jpg-format information (with imagemagick identify) and creates smaller jp2 files (with imagemagick convert)?

Excuse my bad English an thanks in advance,
Kermit
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert jpeg to jpeg 2000 (.jpg to .jp2)

Post by fmw42 »

This post seemingly had nothing to do with Imagemagick Studio, so I moved it to the Users forum.

Please identify your version of Imagemagick and your platform. For the IM developers or any one else to proceed further, we would need to have your input image. You can upload to some free hosting service such as dropbox.com (public folder) and put the URL here.

Note that jp2 is lossless, so -quality probably has no meaning for it. Thus the file sizes will be larger.

When you say bigger, do you mean file size or dimensions.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert jpeg to jpeg 2000 (.jpg to .jp2)

Post by snibgo »

"-quality" does affect the number of bytes in a jp2 file. By reducing the quality, I can get the size as small as I want.

I haven't played much with jp2. I assume that "-quality 100" gives uncompressed, and smaller numbers don't. JP2 isn't (yet) widely supported.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert jpeg to jpeg 2000 (.jpg to .jp2)

Post by fmw42 »

snibgo wrote:"-quality" does affect the number of bytes in a jp2 file. By reducing the quality, I can get the size as small as I want.
I stand corrected. I really have had little to no experience with jp2. So I defer to user snibgo on this topic.

But correct me if I am wrong, does -quality XX have the same meaning for jp2 as for jpg with the same XX. That may be to root of the issue. If they do not mean the same thing (control the same compression and produce the same file size), then expecting the same size for the same XX is not a good assumption.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert jpeg to jpeg 2000 (.jpg to .jp2)

Post by snibgo »

I haven't played, so can't really say, but jpg and jp2 use different algorithms so I expect that "-quality X" gives both different subjective quality and different sizes, for most values of X, comparing jp2 and jpg. It may also depend on the nature of the image.
snibgo's IM pages: im.snibgo.com
Post Reply