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

Thumbnail doesn't have correct rotation #1

Open
miraan opened this issue Aug 21, 2018 · 1 comment
Open

Thumbnail doesn't have correct rotation #1

miraan opened this issue Aug 21, 2018 · 1 comment

Comments

@miraan
Copy link

miraan commented Aug 21, 2018

I love this package, thank you! But the extracted thumbnail doesn't have the right rotation - it always comes out as landscape even for raw images that are portrait. Any ideas for how to fix?

@chrisvince
Copy link

Temporary fix with Sharp and exifr. Here I'm extracting the orientation using exifr, then setting the orientation manually using sharp's withMetadata.

Example:

const sharp = require('sharp')
const dcraw = require('dcraw')
const exifr = require('exifr')

const generateThumbnailFromRawImage = async rawFile => {
  const orientation = await exifr.orientation(rawFile) // extracts the orientation of the original image
  const jpgFile = dcraw(rawFile, { extractThumbnail: true })
  sharp(jpgFile)
    .withMetadata({ orientation }) // manually sets orientation in Sharp
    .toFile('output.jpg')
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants