Hi,

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
28M tags.new.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/tags.new.tif");

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();
exifDirectory.removeField(41488);

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 ?


Cheers
Remi

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to