---------- Forwarded message ---------
From: Clay Jacobs <clayjacobs...@gmail.com>
Date: Tue, Jul 28, 2020 at 3:53 PM
Subject: Tiff appears corrupted on Mac and Linux
To: <us...@commons.apache.org>, <d...@commons.apache.org>



Jacobs, Clay
3:42 PM (6 minutes ago)
to me

Hello,



Wasn’t sure which mailing list to send this to but I figured try both just
in case. We are trying to remove exif data from tiff files. We are
currently using the code below to update the exif and the exif removal
seems to be working. However we’ve discovered that the file opens in
Windows photo viewer, but fails when opened with Linux and Mac using their
default photo viewer applications. We were wondering what could be causing
this to happen and if there’s anything we could do such that the tif files
will actually open on Linux and Mac.



Thanks,

Clay



byte[] imgArray = IOUtils.toByteArray(inputStream);



BufferedImage image =  Imaging.getBufferedImage(imgArray);

Map<String, Object> optionalParams = new HashMap<String, Object>();



TiffImageMetadata metaData = (TiffImageMetadata)
Imaging.getMetadata(imgArray);

TiffOutputSet tiffOutputSet = metaData.getOutputSet();



for(TagInfo tagInfo : ExifTagConstants.ALL_EXIF_TAGS) {

                tiffOutputSet.removeField(tagInfo);

}

for(TagInfo tagInfo : GpsTagConstants.ALL_GPS_TAGS) {

                tiffOutputSet.removeField(tagInfo);

}

optionalParams.put("EXIF", tiffOutputSet);

optionalParams.put(PARAM_KEY_COMPRESSION, TIFF_COMPRESSION_UNCOMPRESSED);

imgArray = Imaging.writeImageToBytes(image, ImageFormats.TIFF,
optionalParams);



inputStream = new ByteArrayInputStream(imgArray);

Reply via email to