PNG to AVIF. Prebuilt & custom-built sharp outputs larger file size w/ bigger `effort`
See original GitHub issuePossible 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 bynpm view sharp dist-tags.latest
.
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?
System:
OS: macOS 13.0
CPU: (10) arm64 Apple M1 Pro
Memory: 689.75 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.11.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.2 - /opt/homebrew/bin/npm
npmPackages:
sharp: 0.31.1 => 0.31.1
or another system bearing the same problem:
System:
OS: Linux 5.15 Amazon Linux 2
CPU: (8) arm64 unknown
Memory: 6.85 GB / 7.76 GB
Container: Yes
Shell: 4.2.46 - /bin/bash
Binaries:
Node: 16.17.1 - /var/lang/bin/node
npm: 8.15.0 - /var/lang/bin/npm
What are the steps to reproduce?
- Install sharp with pre-built binaries
- Use image from
example.png
with the provided code snippet. - Observe the console to see: the higher effort results in bigger file size
On my device(s), it prints as:
Effort 0 size: 342380
Effort 4 size: 356314
Effort 9 size: 361679
What is the expected behaviour?
Increase in effort doesn’t make the size bigger (at least keeps it the same as with the lower effort)
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
const checkEffortAndSize = async (effort) => {
const cmd = sharp(`./example.png`)
const buffer = await cmd
.avif({ quality: 64, effort })
.toBuffer()
console.info(`Effort ${effort} size: ${buffer.byteLength}`)
}
await Promise.all([checkEffortAndSize(0), checkEffortAndSize(9)])
Please provide sample image(s) that help explain this problem
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Using Modern Image Formats: AVIF And WebP
Smaller file size directly impacts the Largest contentful Paint (LCP) metric for the ... (e.g., PNG images with transparent backgrounds) ...
Read more >PNG to AVIF (Online & Free) - Convertio
AVIF file size is 10 times smaller than JPEG with the same image quality. AVIF supports not only Standard Dynamic Range (SDR) images...
Read more >AVIF Converter - unlimited free conversions | avif.io
Convert all image types to AVIF for free. Compress your images now! ... supports png · jpg · webp · gif...
Read more >config "quality" setting for AVIF files doesn't affect generated ...
png , note the generated AVIF file size; expected to get a larger size with quality 50, but got the same AVIF file...
Read more >Load Your Images Faster with the Next-Gen AVIF Format
Generally speaking, if you convert a JPEG or PNG image to a WebP image, the resulting file size will be 30% smaller and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the update, and no worries, as you say this is a question for the libaom maintainers.
The small file size difference probably relates to chroma subsampling (sharp defaults to 4:4:4, i.e. none, whereas libheif defaults to 4:2:0).
Just for the record, libaom maintainers think
libaom
is working as expected.cpu-used
(their internal parameter that is connected tosharp
’seffort
parameter) should affect the processing quality, which in turn results in a different output