Image content compression

K

Kannan

Hi,
Does someone know of any java api's libraries for image compression. I
am not looking for compression into zip. For example a gif file is much
smaller than a jpg file (this is because some information about editing
the page is lost in gif file).

Basically the image file is available as a byte stream (InputStream). I
want to compress the bytes and store image into a database. The image
will be only read from db and noone will be editing the image (which
means that it is okay to loose editing information while compression).

Are there any APIs for this?
 
A

Andrew Thompson

Kannan said:
Does someone know of any java api's libraries for image compression. I
am not looking for compression into zip. For example a gif file is much
smaller than a jpg file

Not always, no. A GIF made from a JPEG with high
compression can actually trun out larger.
..(this is because some information about editing
the page is lost in gif file).

GIF format only supports 256 colors.
Basically the image file is available as a byte stream (InputStream). I
want to compress the bytes and store image into a database. The image
will be only read from db and noone will be editing the image (which
means that it is okay to loose editing information while compression).

Are there any APIs for this?

You can use the javax.imageio.ImageIO class to write the
image as JPEG or PNG format, but core Java (until 1.6)
does not support writing GIF's. You will require a
third-party API/source for writing GIF's pre 1.6.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top