1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-03 10:43:58 +02:00

Use VIPS_META_ORIENTATION in the latest versions of vips

This commit is contained in:
DarthSim 2019-09-19 19:44:11 +06:00
parent 8e69236b6b
commit 447e53fc4e
3 changed files with 11 additions and 4 deletions

11
vips.c
View File

@ -157,7 +157,7 @@ vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out) {
int int
vips_heifload_go(void *buf, size_t len, VipsImage **out) { vips_heifload_go(void *buf, size_t len, VipsImage **out) {
#if VIPS_SUPPORT_HEIF #if VIPS_SUPPORT_HEIF
return vips_heifload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "autorotate", 1, NULL); return vips_heifload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
#else #else
vips_error("vips_heifload_go", "Loading HEIF is not supported"); vips_error("vips_heifload_go", "Loading HEIF is not supported");
return 1; return 1;
@ -165,13 +165,20 @@ vips_heifload_go(void *buf, size_t len, VipsImage **out) {
} }
int int
vips_get_exif_orientation(VipsImage *image) { vips_get_orientation(VipsImage *image) {
#ifdef VIPS_META_ORIENTATION
int orientation;
if (vips_image_get_int(image, VIPS_META_ORIENTATION, &orientation) == 0)
return orientation;
#else
const char *orientation; const char *orientation;
if ( if (
vips_image_get_typeof(image, EXIF_ORIENTATION) == VIPS_TYPE_REF_STRING && vips_image_get_typeof(image, EXIF_ORIENTATION) == VIPS_TYPE_REF_STRING &&
vips_image_get_string(image, EXIF_ORIENTATION, &orientation) == 0 vips_image_get_string(image, EXIF_ORIENTATION, &orientation) == 0
) return atoi(orientation); ) return atoi(orientation);
#endif
return 1; return 1;
} }

View File

@ -337,7 +337,7 @@ func (img *vipsImage) Resize(scale float64, hasAlpa bool) error {
} }
func (img *vipsImage) Orientation() C.int { func (img *vipsImage) Orientation() C.int {
return C.vips_get_exif_orientation(img.VipsImage) return C.vips_get_orientation(img.VipsImage)
} }
func (img *vipsImage) Rotate(angle int) error { func (img *vipsImage) Rotate(angle int) error {

2
vips.h
View File

@ -32,7 +32,7 @@ int vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out);
int vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out); int vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out);
int vips_heifload_go(void *buf, size_t len, VipsImage **out); int vips_heifload_go(void *buf, size_t len, VipsImage **out);
int vips_get_exif_orientation(VipsImage *image); int vips_get_orientation(VipsImage *image);
void vips_strip_meta(VipsImage *image); void vips_strip_meta(VipsImage *image);
int vips_support_smartcrop(); int vips_support_smartcrop();