Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read jpeg2000 files in java

Tags:

java

jpeg2000

I have a code using a byte[] that contains a image jpeg2000 bytes. I want show this in jLabel component howto do this? Anyone have idea or code to do?

like image 692
pedrofernandes Avatar asked Apr 18 '10 16:04

pedrofernandes


People also ask

How do I open JPEG 2000 files?

You can open a JP2 file with various free and commercial image viewing and editing applications, including: Adobe Photoshop (Windows and macOS) CorelDRAW Graphics Suite (Windows and macOS) Apple Preview (macOS)

Why is JPEG 2000 not used?

JPEG 2000 was an entirely different format based on new code; this means that the format was not backward compatible. Those who wanted to support JPEG 2000 would have to code in the new standard while also supporting the original.

Is JPEG 2000 better than JPEG?

Is JPEG or JPEG 2000 better? In terms of pure image quality, JPEG 2000 offers a better output than JPEG. This is because it has higher compression ratios, which means it can handle and compress an image up to 200% more than a JPEG.

What is a JPEG 2000 file?

JPEG 2000 is a wavelet-based image compression method that provides much better image quality at smaller file sizes than the original JPEG method. The JPEG 2000 file format also offers significant improvements over earlier formats by supporting both lossless and lossy image compression within the same physical file.


3 Answers

You would do it in this way

Image img = ImageIO.read(new ByteArrayInputStream(imageBytes));
ImageIcon imgIcon = new ImageIcon(img);

JLabel label = new JLabel(imgIcon);

but the JPG2000 decoder isn't supplied with standard SDK, you should head here (Java Advanced Imaging) and use the right decoder for that format..

like image 81
Jack Avatar answered Oct 01 '22 23:10

Jack


Apparently the support of jpeg2000 / ( .jp2 ) files has been removed from Java Advanced Imaging (JAI).

By un-installing JAI 1.1.3 and installing the older version 1.1, I'm now about to read .jp2 files and no longer see the null pointer.

Version 1.1 is available here. http://download.java.net/media/jai-imageio/builds/release/1.1/

Version 1.1 lists codec's for - g3fax g4fac jiio jp2k jpeg and png

like image 30
Fred F Avatar answered Oct 02 '22 01:10

Fred F


The only options I know are all based on jj2000.

jai-imageio-core provides support through an additional third-party module:

https://github.com/stain/jai-imageio-core

https://github.com/jai-imageio/jai-imageio-jpeg2000

It'll register itself with ImageIO and you'll then be able to read jpeg2000 files as you would any png, bmp or jpeg.

Although jj2000 is in itself an option, the api is not designed for day-to-day use.

Other options include JMRTD, which provides its own wrapping for jj2000, or a commercial offering, JDeli.

like image 45
NoUserException Avatar answered Oct 01 '22 23:10

NoUserException