• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ImageIO.write(...) significantly reduces quality of image...

 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jpg image that I load via ImageIO.read()...

I draw some text on the image and save it via ImageIO.write()...

Now the original image was 37kb. The new image is only 5 kb and has significantly lower quality. I wasn't able to find any quality-adjusting methods in the API

(http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/ImageIO.html)

Does anyone know how to preserve the image quality?

Thanks!
 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I found the solution here:

http://javaalmanac.com/egs/javax.imageio/JpegWrite.html?l=rel

But instead of using the custom ImageWriteParam, use



Otherwise you get exceptions of compression mode not being supported.
 
reply
    Bookmark Topic Watch Topic
  • New Topic