Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.0-alpha2
-
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