Skip to content

Commit

Permalink
Always reset EXIF orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Mar 13, 2024
1 parent 21ad12a commit 4577b92
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ async function convert(inputFile, outputPath = null, quality = 1) {
exif = formatTypes('Exif', exif);
gps = formatTypes('GPS', gps);

// Conversion rotates the image upright
// Conversion rotates the image upright: reset EXIF orientation
ifd0[piexif.TagValues.ImageIFD.Orientation] = 1
if (ifd0[piexif.TagValues.ImageIFD.Orientation] > 4) {
const xd = exif[piexif.TagValues.ExifIFD.PixelXDimension]
const yd = exif[piexif.TagValues.ExifIFD.PixelYDimension]
exif[piexif.TagValues.ExifIFD.PixelXDimension] = yd
exif[piexif.TagValues.ExifIFD.PixelYDimension] = xd
ifd0[piexif.TagValues.ImageIFD.Orientation] = 1
}

const exifBytes = piexif.dump({
Expand Down

0 comments on commit 4577b92

Please sign in to comment.