Reading a 48 bit PPM (PNM) and saving as a 24 bit jpeg using JAI

895 views Asked by At

We had a process where we would read a 24 bit ppm (8 bits per color) file, crop it and resize it then save it as a jpeg thumbnail making use of JAI support of ppm/pnm files.

Due to some quality issues producing the original ppm files it was decidied to create 48 bit ppm files (16 bits per color). Now when we read the PPM file we still get a BufferedImage with a ColorModel of [ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@147f330 transparency = 1 has alpha = false isAlphaPre = false]

If you try and save the image as a jpeg it looks very strange like it is still using 8 bits per color. Whether this happens when the image is loaded or saved is unknown, but we suspect since the ColorModel says 24 pixel bits it seems to be a loading problem. If I give it a 24 bit ppm the reported colour model is the same.

Does JAI only support 24 bit (8 bits per color) ppm images? I was unable to find any definitive answer to that question.

How can I read a 48 bit ppm image and and save it as an 24 bit jpeg?

Any suggestions would be appreciated.

1

There are 1 answers

0
David Oliván On

My 2 cents, try JAI Image I/O Tools, a set of supplementary codecs for JAI, 1.1. Support PPM, but not sure if 48bit PPM also.