Skip to content

Commit a4f488a

Browse files
Merge pull request #59 from pushd/imgproxy_update
FRAM-794 HEIC saving support
2 parents ec9a135 + ecb12e3 commit a4f488a

File tree

6 files changed

+56
-12
lines changed

6 files changed

+56
-12
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Add
5+
- Add `status_codes_total` counter to Prometheus metrics.
6+
- Add client-side decryprion support for S3 integration.
7+
- Add HEIC saving support.
8+
- (pro) Add the `IMGPROXY_VIDEO_THUMBNAIL_KEYFRAMES` config and the [video_thumbnail_keyframes](https://docs.imgproxy.net/latest/generating_the_url?id=video-thumbnail-keyframes) processing option.
9+
- (pro) Add the [video_thumbnail_tile](https://docs.imgproxy.net/latest/generating_the_url?id=video-thumbnail-tile) processing option.
10+
- (pro) Add the `duration` field to the video streams information in the `/info` endpoint response.
11+
12+
### Fix
13+
- (pro) Fix detection of some videos.
14+
- (pro) Fix headers and cookies passthrough when the source is a video.
15+
- (pro) Fix wrong behavior of the `background_alpha` option when the `best` format is used.
16+
- (docker) Fix saving EXIF strings containing invalid UTF-8 characters.
17+
- (docker) Fix possible segfaults while processing HEIC/AVIF images.
18+
- (docker) Fix rendering GIFs embedded in SVGs.
19+
20+
## [3.20.0] - 2023-10-09
21+
### Add
22+
- (pro) Add [info options](https://docs.imgproxy.net/latest/getting_the_image_info?id=info-options) support to the `/info` endpoint.
23+
- (pro) Add video streams info to the `/info` endpoint response.
24+
- (docker) Add support for TIFFs with 16-bit float samples.
25+
- (docker) Add support for TIFFs with the old-style JPEG compression.
26+
27+
### Change
28+
- Limit vector image sizes to `IMGPROXY_MAX_SRC_RESOLUTION`.
29+
- (pro) Respect image orientation when extracting image dimensions for the `/info` endpoint response.
30+
- (pro) Respect `IMGPROXY_WORKERS` and `IMGPROXY_REQUESTS_QUEUE_SIZE` configs in the `/info` endpoint.
31+
- (pro) Collect detailed metrics for the `/info` endpoint.
32+
- (docker) Invalid UTF-8 strings in image metadata are fixed instead of being ignored.
33+
434
### Fix
535
- Fix parsing of HEIF files with large boxes.
636
- Fix wrong colors when the source image has a linear colorspace.

imagetype/imagetype.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,18 @@ func (it Type) SupportsColourProfile() bool {
147147
return it == JPEG ||
148148
it == PNG ||
149149
it == WEBP ||
150+
it == HEIC ||
150151
it == AVIF
151152
}
152153

154+
func (it Type) SupportsQuality() bool {
155+
return it == JPEG ||
156+
it == WEBP ||
157+
it == HEIC ||
158+
it == AVIF ||
159+
it == TIFF
160+
}
161+
153162
func (it Type) SupportsThumbnail() bool {
154163
return it == HEIC || it == AVIF
155164
}

processing/processing.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,6 @@ func ValidatePreferredFormats() error {
8686
return nil
8787
}
8888

89-
func canFitToBytes(imgtype imagetype.Type) bool {
90-
switch imgtype {
91-
case imagetype.JPEG, imagetype.WEBP, imagetype.AVIF, imagetype.TIFF:
92-
return true
93-
default:
94-
return false
95-
}
96-
}
97-
9889
func getImageSize(img *vips.Image) (int, int) {
9990
width, height, _, _ := extractMeta(img, 0, true)
10091

@@ -334,7 +325,7 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
334325
err error
335326
)
336327

337-
if po.MaxBytes > 0 && canFitToBytes(po.Format) {
328+
if po.MaxBytes > 0 && po.Format.SupportsQuality() {
338329
outData, err = saveImageToFitBytes(ctx, po, img)
339330
} else {
340331
outData, err = img.Save(po.Format, po.GetQuality())

vips/vips.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,18 @@ vips_tiffsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
919919
}
920920

921921
int
922-
vips_avifsave_go(VipsImage *in, void **buf, size_t *len, int quality, int speed) {
922+
vips_heifsave_go(VipsImage *in, void **buf, size_t *len, int quality)
923+
{
924+
return vips_heifsave_buffer(
925+
in, buf, len,
926+
"Q", quality,
927+
"compression", VIPS_FOREIGN_HEIF_COMPRESSION_HEVC,
928+
NULL);
929+
}
930+
931+
int
932+
vips_avifsave_go(VipsImage *in, void **buf, size_t *len, int quality, int speed)
933+
{
923934
return vips_heifsave_buffer(
924935
in, buf, len,
925936
"Q", quality,

vips/vips.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func SupportsSave(it imagetype.Type) bool {
247247
sup = hasOperation("webpsave_buffer")
248248
case imagetype.GIF:
249249
sup = hasOperation("gifsave_buffer")
250-
case imagetype.AVIF:
250+
case imagetype.HEIC, imagetype.AVIF:
251251
sup = hasOperation("heifsave_buffer")
252252
case imagetype.BMP:
253253
sup = true
@@ -404,6 +404,8 @@ func (img *Image) Save(imgtype imagetype.Type, quality int) (*imagedata.ImageDat
404404
err = C.vips_webpsave_go(img.VipsImage, &ptr, &imgsize, C.int(quality))
405405
case imagetype.GIF:
406406
err = C.vips_gifsave_go(img.VipsImage, &ptr, &imgsize)
407+
case imagetype.HEIC:
408+
err = C.vips_heifsave_go(img.VipsImage, &ptr, &imgsize, C.int(quality))
407409
case imagetype.AVIF:
408410
err = C.vips_avifsave_go(img.VipsImage, &ptr, &imgsize, C.int(quality), vipsConf.AvifSpeed)
409411
case imagetype.TIFF:

vips/vips.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ int vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int q
9797
int colors);
9898
int vips_webpsave_go(VipsImage *in, void **buf, size_t *len, int quality);
9999
int vips_gifsave_go(VipsImage *in, void **buf, size_t *len);
100+
int vips_heifsave_go(VipsImage *in, void **buf, size_t *len, int quality);
100101
int vips_avifsave_go(VipsImage *in, void **buf, size_t *len, int quality, int speed);
101102
int vips_tiffsave_go(VipsImage *in, void **buf, size_t *len, int quality);
102103

0 commit comments

Comments
 (0)