Skip to content

Exif orientation invalid for a jpeg edited with Snapseed #187

Open
@obr-09

Description

@obr-09

When trying to preserve exif for an image that has been edited with software Snapseed on Android, the compression fails.
The error message is Orientation data type is invalid, and the error is thrown in the following code of copyExifWithoutOrientation.js :

for (
  let i = tiffOffset + ifd0Offset + 2;
  i < endOfTagsOffset;
  i += 12
) {
  const tagId = view.getUint16(i, littleEndian);
  if (tagId == TAG_ID_ORIENTATION) {
    if (view.getUint16(i + 2, littleEndian) !== TAG_TYPE_SHORT) { return reject('Orientation data type is invalid'); }

    if (view.getUint32(i + 4, littleEndian) !== 1) { return reject('Orientation data count is invalid'); }

    view.setUint16(i + 8, 1, littleEndian);
    break;
  }
}

Linking an exemple of failing picture, you can see it fail on the demo with version >= 2.0.1.
jpegEditedWithSnapseed


I don't know if it happens with other editing softwares, or if this is something Snapseed does wrong.
But my suggestion is to try and make this library more resilient, and to not fail the compression if the orientation part did not go as planned

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions