Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6e4e8d7 authored by Jin Park's avatar Jin Park
Browse files

ExifInterface: Fix function for image size update

Existing code assumes that the primary image data is correctly placed.
Since this may be a mistaken assumption, this CL checks the
NewSubfilType value and updates the image size values only if the
tag value equals the original resolution image.

Bug: 29409358
Change-Id: I51cffba870ee29d76118b4c8b72290d1010c6462
parent 04378566
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -3240,21 +3240,28 @@ public class ExifInterface {
            }
        } else {
            // Update for JPEG image
            if (imageType == IFD_TIFF_HINT) {
            ExifAttribute newSubfileTypeAttribute =
                    (ExifAttribute) mAttributes[imageType].get(TAG_NEW_SUBFILE_TYPE);

            if (newSubfileTypeAttribute != null) {
                int newSubfileTypeValue = newSubfileTypeAttribute.getIntValue(mExifByteOrder);

                if (newSubfileTypeValue == ORIGINAL_RESOLUTION_IMAGE) {
                    // Update only for the primary image (OriginalResolutionImage)
                    ExifAttribute pixelXDimAttribute =
                            (ExifAttribute) mAttributes[IFD_EXIF_HINT].get(TAG_PIXEL_X_DIMENSION);
                    ExifAttribute pixelYDimAttribute =
                            (ExifAttribute) mAttributes[IFD_EXIF_HINT].get(TAG_PIXEL_Y_DIMENSION);

                    if (pixelXDimAttribute != null && pixelYDimAttribute != null) {
                        mAttributes[imageType].put(TAG_IMAGE_WIDTH, pixelXDimAttribute);
                        mAttributes[imageType].put(TAG_IMAGE_LENGTH, pixelYDimAttribute);
                } else {
                    retrieveJpegImageSize(in, imageType);
                        return;
                    }
            } else {
                retrieveJpegImageSize(in, imageType);
                }
            }
            retrieveJpegImageSize(in, imageType);
        }
    }

    // Gets the corresponding IFD group index of the given tag number for writing Exif Tags.