This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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.
ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
Thank you.
 
Have you checked out Aspose?
 
subject: How can I reduce the image size of a PNG file
 
It's not a secret anymore!