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 20:46:04 GMT


Gary Lucas commented on IMAGING-170:

This change turned out to be fairly easy. I added the predictor to Apache Commons Imaging
and ran your test image through the read/write process.  The image size for kwf00346.tiff
drops from 3623 KB to 2515 KB without any loss of data.  It's only slightly larger than a
PNG of the same image would be.

Of course, now that Damjan pointed out that ExifWriter is a better solution for you anyway,
it probably doesn't matter.

Anyway, my changes would be ready to go as soon as I do more testing, but there's an issue...
 It's been quite awhile since I've worked on this project, and my development space is out-of-date.
I need get it set up again.  So it may take me some time before I can get this code turned

> 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