Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why new JEPG size is too less  RSS feed

 
Rohit Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried creating new JEPG image using different ways like JAI, JPEGImageEncoder and ImageWriter.

But everytime i found that the resulting JEPG is very less in size (disk size) than the source image.

Why?

I guess some internal compression is taking place.

If yes, how to avoid it?

How to get resultant JEPG equals to source image size?

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Different codes probably use different quality settings. JPEG compression is usually controlled through a quality parameter (often between 0 and 100, with 100 meaning no quality loss). Check the classes you use if there is a way to use this parameter.

For example, the JPEGImageEncoder class uses JPEGEncodeParam, which has a setQuality method.
 
Rohit Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with com.sun.image.codec.jpeg.JPEGEncodeParam, and set quality to 1(100%).
But the resultant JEPG size is more or less for differnt images. But never exactly same.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's just how JPEG works. If you need to preserve the exact pixel values (and image sizes, although I can't see why this would be important), use a PNG instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!