blueimp/JavaScript-Load-Image

Set exif orientation

NilsOlof opened this issue · 0 comments

Thank you for a great library!

I am trying to set the orientation of an image without changing image data:

`

 const imageData = await loadImage(blob, { meta: true });
  loadImage.writeExifData(imageData.imageHead, imageData, "Orientation", 7);
  const resultBlob = await loadImage.replaceHead(blob, imageData.imageHead);

`
The problem is that reading works fine but writing result in the following:

Write: Results in
1: 1
2: 1
3: 3
4: 1
5: 5
6: 1
7: 8
8: 1

So the sample code above results in orientation 8

piexif.js have the same problem.

For reference:

The 8 EXIF orientation values are numbered 1 to 8.

1 = 0 degrees: the correct orientation, no adjustment is required.
2 = 0 degrees, mirrored: image has been flipped back-to-front.
3 = 180 degrees: image is upside down.
4 = 180 degrees, mirrored: image has been flipped back-to-front and is upside down.
5 = 90 degrees: image has been flipped back-to-front and is on its side.
6 = 90 degrees, mirrored: image is on its side.
7 = 270 degrees: image has been flipped back-to-front and is on its far side.
8 = 270 degrees, mirrored: image is on its far side.

I need the 6 orientation. Any suggestions what to do?