Paul Williams created IMAGING-299:
-------------------------------------
Summary: updateExifMetadataLossless making more changes than
requested
Key: IMAGING-299
URL: https://issues.apache.org/jira/browse/IMAGING-299
Project: Commons Imaging
Issue Type: Bug
Components: Format: JPEG
Affects Versions: 1.0-alpha2
Environment: Maven Dependency:
{noformat}
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-alpha2</version>
</dependency>{noformat}
MacOS 11.3 using
{noformat}
openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.2+7, mixed mode,
sharing){noformat}
I've attempted to attach the original image, but upload fails. Do you accept
1.7MB jpegs?
Reporter: Paul Williams
Using the below code based on provided sample doesn't just remove the
TIFF_TAG_MODEL field, but moves its value to another tag, and further relocates
GPS Version ID.
{code:java}
FileUtils.copyFile(src, dst);
try (FileOutputStream fos = new FileOutputStream(dst);
OutputStream os = new BufferedOutputStream(fos)) {
final ImageMetadata metadata = Imaging.getMetadata(src);
final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
final TiffImageMetadata exif = jpegMetadata.getExif();
final TiffOutputSet outputSet = exif.getOutputSet();
final TiffOutputDirectory exifDirectory = outputSet.getRootDirectory();
exifDirectory.removeField(TiffTagConstants.TIFF_TAG_MODEL);
new ExifRewriter().updateExifMetadataLossless(src, os,
outputSet);
}
{code}
The resultant diff from Exiftool is:
{noformat}
diff a.txt b.txt
2c2
< [System] File Name : a.jpg
---
> [System] File Name : b.jpg
5,7c5,7
< [System] File Modification Date/Time : 2021:05:03 09:34:28+00:00
< [System] File Access Date/Time : 2021:05:03 09:34:29+00:00
< [System] File Inode Change Date/Time : 2021:05:03 09:34:28+00:00
---
> [System] File Modification Date/Time : 2021:05:03 09:34:43+00:00
> [System] File Access Date/Time : 2021:05:03 09:34:43+00:00
> [System] File Inode Change Date/Time : 2021:05:03 09:34:43+00:00
23d22
< [IFD0] Camera Model Name : NIKON D90
67d65
< [GPS] GPS Version ID : 2.3.0.0
74c72
< [IFD1] Thumbnail Offset : 1514
---
> [IFD1] Thumbnail Offset : 1372
134a133
> [XMP-exif] GPS Version ID : 2.3.0.0
136a136
> [XMP-tiff] Camera Model Name : NIKON D90{noformat}
I attach the original photograph
--
This message was sent by Atlassian Jira
(v8.3.4#803005)