Skip to content

Commit

Permalink
Use withoutEnlargement instead of sharp.metadata() (#44890)
Browse files Browse the repository at this point in the history
  • Loading branch information
ITJesse authored Jan 17, 2023
1 parent 3a9bfe6 commit aeef38e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/next/src/server/image-optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,9 @@ export async function optimizeImage({
if (height) {
transformer.resize(width, height)
} else {
const { width: metaWidth } = await transformer.metadata()

if (metaWidth && metaWidth > width) {
transformer.resize(width)
}
transformer.resize(width, undefined, {
withoutEnlargement: true,
})
}

if (contentType === AVIF) {
Expand Down

0 comments on commit aeef38e

Please sign in to comment.