Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Reduce image size after converting to TIFF image with compression type

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




Using the above code to convert from jpeg to tiff.
I want to compress the image so using compression types from http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/imageio/plugins/tiff/TIFFImageWriteParam.html




Is there any other compression type or way which can give me more smaller or same size as that of original image?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Might be relevant. I've just noticed that what one creates the
then FileImageOutputStreamSpi creates javax.imageio.stream.FileImageOutputStream, which in turn does new RandomAccessFile(f, "rw") and that does not overwrite / truncate the output file, but re-uses it. That means TIFFImageWriter writes to it up to necessary position, but the trailing "junk" stays there. Which means that if you write in your test scenario to the same output file, and by chance started with uncompressed scenario, then filesize will not change and will stay the same but modification time changes.

If that is not your case, then I would say that LZW (lossless compression) generally cannot be better than JPEG (lossy). Also, what do you refer as "Original image"? You should refer raster as original image, e.g. try to write to TIFF without compression – that will be your baseline.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic