Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I reduce the image size of a PNG file

 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic