John
John

Reputation: 855

Bash: How to get size of image compressed with JPEG2000

I encoded image with jPEG2000 standard, how to get size of image after compression.

identify inputimage.pgm 

works but

identify inputimage.jpc

does not work. error is "identify: no decode delegate for this image format `J2K' @ error/constitute.c/ReadImage/501."

Upvotes: 1

Views: 435

Answers (3)

Jérôme Pouiller
Jérôme Pouiller

Reputation: 10267

Error messages says identify did not find necessary library to handle JPEG2000. You can check output of identify -list format to confirm that.

Indeed, it seems that JPEG2000 support is not enable in last versions of Ubuntu. Debian fixed this issue a while ago. So I suggest:

  • Install another distribution (Debian for exemple)
  • Rebuild imagemagick package with support for JPEG2000

Under Ubuntu, you can rebuild ImageMagick with JPEG2000 support following these steps:

apt-get source imagemagick
sudo apt-get build-dep imagemagick
sudo apt-get install libopenjp2-7-dev
dpkg-buildpackage -uc -us
sudo dpkg -i *deb

Upvotes: 1

Mark Setchell
Mark Setchell

Reputation: 208107

You can test which image formats your ImageMagick installation is able to read/write by running:

identify -list format

And further, which files ImageMagick is able to read/write by "delegating" out to a "helper program", by running:

identify -list delegate

If you are on Linux and missing JPEG2000, you will probably need to have installed the following before running ./configure to configure ImageMagick:

  • pkg-config
  • libopenjpeg
  • libopenjp2-7-dev

On a Mac under macOS at least, that means you need to have done:

brew install openjpeg
brew install imagemagick --with-openjpeg      # Use "reinstall" if already installed

Upvotes: 0

slashcool
slashcool

Reputation: 178

If ImageMagick does not the trick, you can try using exiftool:

exiftool -FileSize inputimage.jpc

Upvotes: 0

Related Questions