wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes How can I reduce the image size of a PNG file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How can I reduce the image size of a PNG file" Watch "How can I reduce the image size of a PNG file" New topic
Author

How can I reduce the image size of a PNG file

ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
Hi,

I am using the following code to convert an image to a PNG file:



I would like to know how can I reduce the file size of the converted file.
I read there is a trick which can reduce the color map of the result image without losing much image quality.

Can you please tell me how can I do that in java?

Thank you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
There's example code that shows how to compress an image to a JPEG here. It's possible that it works out of the box with PNGs as well (I'm not sure about the algorithms PNG uses), or -worst case- you can write a JPEG in the desired quality/compression, read it back into memory, and then write it as a PNG.


Ping & DNS - my free Android networking tools app
ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
Thank you.
 
Don't get me started about those stupid light bulbs.
 
subject: How can I reduce the image size of a PNG file
 
Similar Threads
How can I merge 18 images to 1 images?
Writing Image onto a WordDoc
Showing JSP output in XSL
Error in Dowlnoading
Crop an Image