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

updateExifMetadataLossless lost the first character of a String

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0-alpha2
    • 1.0.0-alpha5
    • Format: JPEG
    • None

    Description

      I try to use TiffOutputSet to generate a new image. However, if a tag that contains String, the program may miss the first character of the String.

      package org.apache.commons.imaging;
      
      import org.apache.commons.imaging.common.ImageMetadata;
      import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
      import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
      import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
      import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
      
      import java.io.BufferedOutputStream;
      import java.io.File;
      import java.io.FileOutputStream;
      import java.io.IOException;
      
      public class LibraryTest {
      
          public static void main(String[] args) throws ImagingException, IOException {
              File source = new File("/home/kinow/Desktop/iPhone12-geotag.JPG");
              File result = new File("/home/kinow/Desktop/editted-iPhone12-geotag.JPG");
              final ImageMetadata metadata = Imaging.getMetadata(source);
              final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
              final TiffImageMetadata exif = jpegMetadata.getExif();
              TiffOutputSet outputSet = exif.getOutputSet();
              BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(result));
              new ExifRewriter().updateExifMetadataLossless(source, bufferedOutputStream, outputSet);
          }
      }

      This is the sample code.

      Tag value in original image

      Tag value in output image

      Attachments

        1. Screen Shot 2021-11-26 at 4.01.21 PM-1.png
          5 kB
          Sicheng Yang
        2. Screen Shot 2021-11-26 at 4.01.06 PM-1.png
          5 kB
          Sicheng Yang
        3. iPhone12-geotag.JPG
          5.03 MB
          Sicheng Yang

        Activity

          People

            kinow Bruno P. Kinoshita
            yangsicheng Sicheng Yang
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m