commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Lucas (JIRA)" <>
Subject [jira] [Commented] (IMAGING-170) TIFF image gains significant size using TiffImageWriterLossless
Date Thu, 17 Sep 2015 12:38:04 GMT


Gary Lucas commented on IMAGING-170:

Interesting ideas.    

For Remigiusz Malessa:  I can see that you wouldn't be interested in the JPEG compression
even if it were easy to implement (it's not hard, just more coding than I have time to do
right now). As you know, JPEG achieves its large compression ratios by sacrificing some of
the less important information in the image. On the the other hand, the predictor-based LZW
is a non-lossy data compression scheme which preserves the original image with pixel-for-pixel
fidelity.   The predictor just improves the compression ratio in cases such as your photograph
of a cameo.  I'll take a look at it this weekend and see what I can do.

As I recall, one of the unit tests built into the Apache Commons Imaging build process is
the "round-trip test" to make sure that the output data matches the input data.  I will have
to check and see what's involved in extending it to also test the predictor.

If I post code, are you set up to build a new Apache Commons Imaging jar using maven?  Also,
it there some place you can temporarily post original images for me to download and test?

For Sebb:  I like your idea.  It's kind of outside the original concept in the Apache Commons
Imaging design. So it would mean adding some new methods and perhaps a new class for processing
the data.  The main value of this feature would be time to process images. If you were only
doing one or two images, it wouldn't matter much, but if you were doing a large number it
would definitely improve production times.  It also has the virtue of guaranteeing that the
image content of the input TIFF file doesn't change.  For folks doing archival and historical
work, that feature would be very reassuring. 

> TIFF image gains significant size using TiffImageWriterLossless
> ---------------------------------------------------------------
>                 Key: IMAGING-170
>                 URL:
>             Project: Commons Imaging
>          Issue Type: Bug
>          Components: Format: TIFF
>    Affects Versions: 1.0
>         Environment: System: Fedora release 21, kernel version: 3.18.7-200.fc21.x86_64,
JAVA: openjdk version "1.8.0_31", IDE: Eclipse Kepler 2, Build id: 20140224-0627
>            Reporter: Remigiusz Malessa
>            Priority: Minor
>         Attachments: kwf00346.tif
> Good afternoon, 
> I am posting an issue report as suggested by mr Benedikt Ritter. It's my first issue
report and I've just recently started using the Commons Imaging,  so please go easy on me.

> ------------------------------------------------
> Using Commons Imaging I am reading a Tiff image (will attempt to attach it to this ticket),
then I remove a tag (Focal Plane Resolution Unit) and then I save the new TiffOutputSet to
the system using TiffImageWriterLossless.
> The original image is 15MB, the new image (with the Tag removed) is 28MB.
> Here's how I do it:
> {|borderStyle=solid}
> import java.awt.image.BufferedImage;
> import;
> import;
> import;
> import;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
> import org.apache.camel.Exchange;
> import org.apache.commons.imaging.ImageFormats;
> import org.apache.commons.imaging.ImageReadException;
> import org.apache.commons.imaging.ImageWriteException;
> import org.apache.commons.imaging.Imaging;
> import org.apache.commons.imaging.common.ImageMetadata;
> import org.apache.commons.imaging.formats.tiff.TiffField;
> import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
> import org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossless;
> import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
> import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
> File tInputFile = new File("/home/rem/TEMP/tags.original.tif");
> File toutputFile = new File("/home/rem/TEMP/");
> final BufferedImage image = Imaging.getBufferedImage(tInputFile);
> ImageMetadata tMetadata = Imaging.getMetadata(tInputFile);
> TiffImageMetadata imageMetadata = (TiffImageMetadata) tMetadata;
> outputSet = imageMetadata.getOutputSet();
> TiffOutputDirectory exifDirectory = outputSet.getExifDirectory(); 
> exifDirectory.removeField(41488);
> ImageFormats format = ImageFormats.TIFF;
> Map<String, Object> params = new HashMap<String, Object>();
> BufferedImage image = Imaging.getBufferedImage(tInputFile);
> byte[] bytes = Imaging.writeImageToBytes(image, format, params);
> TiffImageWriterLossless writerLossLess = new TiffImageWriterLossless(bytes);
> writerLossLess.write(os, outputSet);
> {code}

This message was sent by Atlassian JIRA

View raw message