In sharp, AVIF bytes grow fast with quality: a 1920 × 1280 photo of 576.8 KB came out at 54.4 KB at q30, 119.0 KB at q50 (sharp's default) and 332.7 KB at q80. That is 6.1 times the bytes from the bottom of the ladder to the top. Encode time stayed between 0.6 and 1.2 seconds on an M1 Pro at the default effort.
What does each quality setting cost?
The script, run from a folder with sharp installed:
import sharp from ' sharp ' ; import { readFile } from ' node:fs/promises ' ;
const input = await readFile ( ' jpg-sample-photo-original.jpg ' ); const median = ( a ) => [... a ]. sort (( x , y ) => x - y )[ Math . floor ( a . length / 2 )];
await sharp ( input ). avif ({ quality : 50 }). toBuffer (); // warm-up console . log ( ' quality bytes KB ms(median of 5) ' ); for ( const q of [ 30 , 40 , 50 , 60 , 70 , 80 ]) { const times = []; let bytes = 0 ; for ( let i = 0 ; i < 5 ; i ++ ) { const t = performance . now (); const out = await sharp ( input ). avif ({ quality : q }). toBuffer (); times .…