You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constsharp=require('sharp');constpath=require('path');constfs=require('fs');// Function to convert an image to AVIFasyncfunctionconvertToAvif(inputPath){try{// Ensure the input file existsif(!fs.existsSync(inputPath)){console.error('Input file does not exist:',inputPath);return;}// Convert the image to AVIF formatawaitsharp(inputPath).keepMetadata().toFile('output.keepMetadata.jpeg');awaitsharp(inputPath).keepMetadata().toFormat('avif').toFile('output.keepMetadata.avif');awaitsharp(inputPath).keepMetadata().toFormat('webp').toFile('output.keepMetadata.webp');awaitsharp(inputPath).withMetadata().toFile('output.withMetadata.jpeg');awaitsharp(inputPath).withMetadata().toFormat('avif').toFile('output.withMetadata.avif');awaitsharp(inputPath).withMetadata().toFormat('webp').toFile('output.withMetadata.webp');awaitsharp(inputPath).toFile('output.jpeg');awaitsharp(inputPath).toFormat('avif').toFile('output.avif');awaitsharp(inputPath).toFormat('webp').toFile('output.webp');awaitsharp(inputPath).rotate().toFile('output.rotate.jpeg');awaitsharp(inputPath).rotate().toFormat('avif').toFile('output.rotate.avif');awaitsharp(inputPath).rotate().toFormat('webp').toFile('output.rotate.webp');awaitsharp(inputPath).keepExif().toFile('output.keepExif.jpeg');awaitsharp(inputPath).keepExif().toFormat('avif').toFile('output.keepExif.avif');awaitsharp(inputPath).keepExif().toFormat('webp').toFile('output.keepExif.webp');console.log(`Image successfully converted`);}catch(error){console.error('Error converting image to WEBP:',error.message);}}// Replace with your input and output file pathsconstinputImagePath=path.resolve(__dirname,'input.jpg');// Adjust the filename and extension// const outputImagePath = path.resolve(__dirname, 'output.latestsharp.webp');// Call the conversion functionconvertToAvif(inputImagePath);
What is the expected behaviour?
I expect to see the correct orientation for all output images. However, I see error only for AVIF format
The only case when AVIF format is correctly oriented is when using rotate().
JPEG :
.keepMetadata().toFile('output.keepMetadata.jpeg'); => OK
.withMetadata().toFile('output.withMetadata.jpeg'); => OK
.toFile('output.jpeg'); => KO
.rotate().toFile('output.rotate.jpeg'); => OK
.keepExif().toFile('output.keepExif.jpeg'); => OK
WEBP
.keepMetadata().toFile('output.keepMetadata.webp'); => OK
.withMetadata().toFile('output.withMetadata.webp'); => OK
.toFile('output.webp'); => KO
.rotate().toFile('output.rotate.webp'); => OK
.keepExif().toFile('output.keepExif.webp'); => OK
AVIF
.keepMetadata().toFile('output.keepMetadata.avif'); => KO
.withMetadata().toFile('output.withMetadata.avif'); => KO
.toFile('output.avif'); => KO .rotate().toFile('output.rotate.avif'); => OK
.keepExif().toFile('output.keepExif.avif'); => KO
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Please provide sample image(s) that help explain this problem
The text was updated successfully, but these errors were encountered:
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of
sharp
that is not the latest, please open an issue against that package instead.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?What are the steps to reproduce?
What is the expected behaviour?
I expect to see the correct orientation for all output images. However, I see error only for AVIF format
The only case when AVIF format is correctly oriented is when using
rotate()
.JPEG :
.keepMetadata().toFile('output.keepMetadata.jpeg'); => OK
.withMetadata().toFile('output.withMetadata.jpeg'); => OK
.toFile('output.jpeg'); => KO
.rotate().toFile('output.rotate.jpeg'); => OK
.keepExif().toFile('output.keepExif.jpeg'); => OK
WEBP
.keepMetadata().toFile('output.keepMetadata.webp'); => OK
.withMetadata().toFile('output.withMetadata.webp'); => OK
.toFile('output.webp'); => KO
.rotate().toFile('output.rotate.webp'); => OK
.keepExif().toFile('output.keepExif.webp'); => OK
AVIF
.keepMetadata().toFile('output.keepMetadata.avif'); => KO
.withMetadata().toFile('output.withMetadata.avif'); => KO
.toFile('output.avif'); => KO
.rotate().toFile('output.rotate.avif'); => OK
.keepExif().toFile('output.keepExif.avif'); => KO
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Please provide sample image(s) that help explain this problem
The text was updated successfully, but these errors were encountered: