bimg icon indicating copy to clipboard operation
bimg copied to clipboard

png not compressing (quality) and it's size is increasing

Open xerenahmed opened this issue 4 years ago • 1 comments

code sample:

options := bimg.Options{
	Quality:  quality,
	Lossless: true,
}
newImage := imgBuf.Bytes()
newImage, err = bimg.NewImage(imgBuf.Bytes()).Process(options)

image is jpeg by default.

the image: 00042b7d-d3d4-466a-8e79-b49f22904b98_big

xerenahmed avatar Jan 04 '22 17:01 xerenahmed

What's the expectation here? PNG is a lossless format and optimized for computer graphics, not photos. JPEG achieves its smaller size due to its lossy compression. So I don't see how the PNG could be smaller than the JPEG, even at high (lossless!) compression.

IMO the only way out would be to use a lossy compression (imagequant does that for example), but that more or less destroys the advantage of PNG.

aksdb avatar Feb 27 '22 12:02 aksdb