Uploaded image for project: 'Commons Imaging'
  1. Commons Imaging
  2. IMAGING-299

updateExifMetadataLossless making more changes than requested

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.0-alpha2
    • None
    • Format: JPEG
    • None

    Description

      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.

      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);
      }
      

      The resultant diff from Exiftool is:

      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

      I can not attach the 1.7MB jpeg that has this issue. A smaller lower resolution version of the same image results in different output

      Attachments

        Activity

          People

            Unassigned Unassigned
            paulswilliams Paul Williams
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: