File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 41509
    
  53
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can I reduce the image size of a PNG file