commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remi Malessa <>
Subject [imaging] Images gain size.
Date Mon, 27 Apr 2015 08:44:26 GMT

I work with scanned Tiff images. Because of the type of scanner used, 
there is a tag I need to remove.
I tried to accomplish this with Commons Imaging libraries.

The problem is, the images gain significantly in size, after the operation:

15M tags.original.tif

Here's how I remove the Tag:

File tInputFile = new File("/home/rem/TEMP/tags.original.tif");
File toutputFile = new File("/home/rem/TEMP/");

final BufferedImage image = Imaging.getBufferedImage(tInputFile);

TiffOutputSet outputSet = null;
OutputStream os = new FileOutputStream(toutputFile);

ImageMetadata tMetadata = Imaging.getMetadata(tInputFile);

TiffImageMetadata imageMetadata = (TiffImageMetadata) tMetadata;
outputSet = imageMetadata.getOutputSet();
TiffOutputDirectory exifDirectory = outputSet.getExifDirectory();

ImageFormats format = ImageFormats.TIFF;
Map<String, Object> params = new HashMap<String, Object>();
byte[] bytes = Imaging.writeImageToBytes(image, format, params);

TiffImageWriterLossless writerLossLess = new TiffImageWriterLossless(bytes);
writerLossLess.write(os, outputSet);

Would much appreciate if somebody could tell me if there is a method to 
trim or prevent creation of the extra data when saving the image + set, 
to a file ?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message