next.js
ee8286f1 - fix(next/image): use `image-size` pkg as additional format detector (#82538)

Commit
136 days ago
fix(next/image): use `image-size` pkg as additional format detector (#82538) In a previous PR https://github.com/vercel/next.js/pull/82118 we added a fallback to `sharp().metadata()` when the magic number didn't detect the image format in order to improve detection. But `sharp` can be slow to read metadata, so we should avoid it if we can. So this PR uses the existing `image-size` package to detect the content type in JS and only then does it fallback to the native `sharp` code if necessary. No tests were added since this doesn't change the behavior, only performance.
Author
Parents
Loading