1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-06-17 22:37:33 +02:00

HEIC saving support

This commit is contained in:
DarthSim
2023-11-18 20:32:05 +03:00
parent 8887f093ec
commit 707a24e59d
6 changed files with 25 additions and 11 deletions

View File

@ -85,15 +85,6 @@ func ValidatePreferredFormats() error {
return nil
}
func canFitToBytes(imgtype imagetype.Type) bool {
switch imgtype {
case imagetype.JPEG, imagetype.WEBP, imagetype.AVIF, imagetype.TIFF:
return true
default:
return false
}
}
func getImageSize(img *vips.Image) (int, int) {
width, height, _, _ := extractMeta(img, 0, true)
@ -339,7 +330,7 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
err error
)
if po.MaxBytes > 0 && canFitToBytes(po.Format) {
if po.MaxBytes > 0 && po.Format.SupportsQuality() {
outData, err = saveImageToFitBytes(ctx, po, img)
} else {
outData, err = img.Save(po.Format, po.GetQuality())