WebP image size is increased when processed through sharp
What are the steps to reproduce?
This is actual image but it can be replicated using other image too https://s-usweb.dotomi.com/images/63249/ADS_MP_60682/970x250/bg_img_CAR_Summer_OrangeJuice_20240329.webp
When sending this image to sharp the returned image is increased size if we use the same dimension for e.g. this image dimension is 1940*500 if its just processed to have same dimension its size is increased by more that twice. Image size is areoung 130KB but passing to sharp its around 235KB
What is the expected behaviour?
Sizes should be less than or equal to original size, not larger.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
sharp(inputBuffer) .resize(1940, 500) .toFile('output.webp', (err, info) => { ... });
Please provide sample image(s) that help explain this problem
https://s-usweb.dotomi.com/images/63249/ADS_MP_60682/970x250/bg_img_CAR_Summer_OrangeJuice_20240329.webp
On processing with sharp
https://s-usweb.dotomi.com/imageresizer/63249/?img=https%3A%2F%2Fs-usweb.dotomi.com%2Fimages%2F63249%2FADS_MP_60682%2F970x250%2Fbg_img_CAR_Summer_OrangeJuice_20240329.webp&ts1716916460293
Even if I reduce the size of the image it is still higher than actual image. On the service deployed we can change height and width based as below from query params to test that https://s-usweb.dotomi.com/imageresizer/63249/?img=https%3A%2F%2Fs-usweb.dotomi.com%2Fimages%2F63249%2FADS_MP_60682%2F970x250%2Fbg_img_CAR_Summer_OrangeJuice_20240329.webp&w=1800&h=350
The input WebP image was created with a "quality" ("Base Q") of approximately 44.
$ webpinfo -bitstream_info bg_img_CAR_Summer_OrangeJuice_20240329.webp
File: bg_img_CAR_Summer_OrangeJuice_20240329.webp
RIFF HEADER:
File size: 137626
Chunk VP8X at offset 12, length 18
ICCP: 1
Alpha: 0
EXIF: 1
XMP: 0
Animation: 0
Canvas size 1940 x 500
Chunk ICCP at offset 30, length 488
Chunk VP8 at offset 518, length 136914
Width: 1940
Height: 500
Alpha: 0
Animation: 0
Format: Lossy (1)
Parsing lossy bitstream...
Key frame: Yes
Profile: 0
Display: Yes
Part. 0 length: 19756
Width: 1940
X scale: 0
Height: 500
Y scale: 0
Color space: 0
Clamp type: 0
Use segment: 1
Update map: 1
Update data: 1
Absolute delta: 1
Quantizer: 44 37 31 19
Filter strength: 14 8 6 17
Prob segment: 126 53 184
Simple filter: 0
Level: 17
Sharpness: 0
Use lf delta: 0
Total partitions: 1
Base Q: 44
DQ Y1 DC: 0
DQ Y2 DC: 0
DQ Y2 AC: 0
DQ UV DC: -2
DQ UV AC: -2
Chunk EXIF at offset 137432, length 194
The default WebP output "quality" setting is 80.
https://sharp.pixelplumbing.com/api-output#webp
Thank you for the quick feedback. Appreciate taking time reviewing it.