Hello Remi,

2015-04-27 10:44 GMT+02:00 Remi Malessa <[email protected]>:

> 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 ?
>

I'll need some time to look into this. I'll try to put a minimal test
together to reproduce this.

br,
Benedikt


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


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Reply via email to