Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: auto-rotation of images not applied without other transformation #3422

Closed
3 tasks done
rexxars opened this issue Oct 31, 2022 · 2 comments
Closed
3 tasks done

Bug: auto-rotation of images not applied without other transformation #3422

rexxars opened this issue Oct 31, 2022 · 2 comments

Comments

@rexxars
Copy link
Contributor

rexxars commented Oct 31, 2022

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

 System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Pro
    Memory: 884.92 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
  npmPackages:
    sharp: 0.31.1 => 0.31.1

What are the steps to reproduce?

  1. Load an image with an EXIF orientation tag such as 4, 5 or 7
  2. Call .rotate() on the pipeline
  3. Output the image using toFile()
  4. Observe the lack of auto-rotation

What is the expected behaviour?

The images should be automatically rotated based on their exif orientation tag.

(According to the documentation; Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.)

All of these images have an exif orientation, but are not automatically oriented. If you add a resize(200, 200) call to the pipeline, it will however rotate them correctly.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

Download source images from here: https://timely-scone-c18287.netlify.app/images.zip
(They are also available as https://timely-scone-c18287.netlify.app/input-orientation1.jpg through 8)

const sharp = require('sharp')

async function run() {
  for (let i = 1; i <= 8; i++) {
    sharp(`./input-orientation${i}.jpg`)
      .rotate()
      .png()
      .toFile(`output-orientation${i}.png`)
  }
}

run()

Please provide sample image(s) that help explain this problem

(provided as links in order for GitHub not to alter image and adjust any exif data)

https://timely-scone-c18287.netlify.app/input-orientation4.jpg
https://timely-scone-c18287.netlify.app/input-orientation5.jpg
https://timely-scone-c18287.netlify.app/input-orientation7.jpg

@rexxars rexxars added the triage label Oct 31, 2022
@lovell lovell added this to the v0.31.2 milestone Nov 2, 2022
@lovell
Copy link
Owner

lovell commented Nov 2, 2022

This issue is caused by the same regression behind #3391, but it looks like the fix for that didn't quite go far enough.

Commit 5b0fba4 massively improves the test coverage of auto-rotate logic, including the scenario in this issue, plus of course fixes the problem.

This will be in v0.31.2, thanks for reporting.

@lovell
Copy link
Owner

lovell commented Nov 4, 2022

v0.31.2 now available.

@lovell lovell closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants