mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 04:02:29 +02:00
Fix processing images with embedded profiles
This commit is contained in:
@@ -581,8 +581,6 @@ func processImage(ctx context.Context) ([]byte, context.CancelFunc, error) {
|
||||
checkTimeout(ctx)
|
||||
}
|
||||
|
||||
C.vips_strip_meta(img)
|
||||
|
||||
return vipsSaveImage(img, po.Format, po.Quality)
|
||||
}
|
||||
|
||||
@@ -669,11 +667,7 @@ func vipsSaveImage(img *C.VipsImage, imgtype imageType, quality int) ([]byte, co
|
||||
case imageTypeJPEG:
|
||||
err = C.vips_jpegsave_go(img, &ptr, &imgsize, C.int(quality), cConf.JpegProgressive)
|
||||
case imageTypePNG:
|
||||
if err = C.vips_pngsave_go(img, &ptr, &imgsize, cConf.PngInterlaced, 1); err != 0 {
|
||||
C.g_free_go(&ptr)
|
||||
logWarning("Failed to save PNG; Trying not to embed icc profile")
|
||||
err = C.vips_pngsave_go(img, &ptr, &imgsize, cConf.PngInterlaced, 0)
|
||||
}
|
||||
err = C.vips_pngsave_go(img, &ptr, &imgsize, cConf.PngInterlaced)
|
||||
case imageTypeWEBP:
|
||||
err = C.vips_webpsave_go(img, &ptr, &imgsize, C.int(quality))
|
||||
case imageTypeGIF:
|
||||
|
35
vips.c
35
vips.c
@@ -116,19 +116,6 @@ vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VIPS_META_ORIENTATION
|
||||
int
|
||||
vips_get_exif_orientation(VipsImage *image) {
|
||||
int orientation;
|
||||
|
||||
if (
|
||||
vips_image_get_typeof(image, VIPS_META_ORIENTATION) == G_TYPE_INT &&
|
||||
vips_image_get_int(image, VIPS_META_ORIENTATION, &orientation) == 0
|
||||
) return orientation;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int
|
||||
vips_get_exif_orientation(VipsImage *image) {
|
||||
const char *orientation;
|
||||
@@ -140,19 +127,6 @@ vips_get_exif_orientation(VipsImage *image) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif // VIPS_META_ORIENTATION
|
||||
|
||||
void
|
||||
vips_strip_meta(VipsImage *image) {
|
||||
#ifdef VIPS_META_ORIENTATION
|
||||
vips_image_remove(image, VIPS_META_ORIENTATION);
|
||||
#endif
|
||||
|
||||
vips_image_remove(image, VIPS_META_EXIF_NAME);
|
||||
vips_image_remove(image, VIPS_META_PHOTOSHOP_NAME);
|
||||
|
||||
vips_image_remove(image, EXIF_ORIENTATION);
|
||||
}
|
||||
|
||||
int
|
||||
vips_support_smartcrop() {
|
||||
@@ -478,20 +452,17 @@ vips_arrayjoin_go(VipsImage **in, VipsImage **out, int n) {
|
||||
|
||||
int
|
||||
vips_jpegsave_go(VipsImage *in, void **buf, size_t *len, int quality, int interlace) {
|
||||
return vips_jpegsave_buffer(in, buf, len, "Q", quality, "optimize_coding", TRUE, "interlace", interlace, NULL);
|
||||
return vips_jpegsave_buffer(in, buf, len, "profile", "none", "Q", quality, "strip", TRUE, "optimize_coding", TRUE, "interlace", interlace, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int embed_profile) {
|
||||
if (embed_profile)
|
||||
return vips_pngsave_buffer(in, buf, len, "filter", VIPS_FOREIGN_PNG_FILTER_NONE, "interlace", interlace, NULL);
|
||||
|
||||
vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace) {
|
||||
return vips_pngsave_buffer(in, buf, len, "profile", "none", "filter", VIPS_FOREIGN_PNG_FILTER_NONE, "interlace", interlace, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
vips_webpsave_go(VipsImage *in, void **buf, size_t *len, int quality) {
|
||||
return vips_webpsave_buffer(in, buf, len, "Q", quality, NULL);
|
||||
return vips_webpsave_buffer(in, buf, len, "Q", quality, "strip", TRUE, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
|
2
vips.h
2
vips.h
@@ -73,7 +73,7 @@ int vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, d
|
||||
int vips_arrayjoin_go(VipsImage **in, VipsImage **out, int n);
|
||||
|
||||
int vips_jpegsave_go(VipsImage *in, void **buf, size_t *len, int quality, int interlace);
|
||||
int vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int embed_profile);
|
||||
int vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace);
|
||||
int vips_webpsave_go(VipsImage *in, void **buf, size_t *len, int quality);
|
||||
int vips_gifsave_go(VipsImage *in, void **buf, size_t *len);
|
||||
int vips_icosave_go(VipsImage *in, void **buf, size_t *len);
|
||||
|
Reference in New Issue
Block a user