Adding support for heif (i.e. heic files).

This commit is contained in:
Jeremy Gordon 2019-09-24 11:57:29 -07:00 committed by Paul van Santen
parent 5a9d7f21d9
commit f9eadf55bb
No known key found for this signature in database
GPG key ID: AD10F40CB69516B6
6 changed files with 58 additions and 3 deletions

33
vips.h
View file

@ -32,7 +32,10 @@ enum types {
GIF,
PDF,
SVG,
MAGICK
MAGICK,
#if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
HEIF,
#endif
};
typedef struct {
@ -156,6 +159,11 @@ vips_type_find_bridge(int t) {
if (t == MAGICK) {
return vips_type_find("VipsOperation", "magickload");
}
#if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
if (t == HEIF) {
return vips_type_find("VipsOperation", "heifload");
}
#endif
return 0;
}
@ -173,6 +181,11 @@ vips_type_find_save_bridge(int t) {
if (t == JPEG) {
return vips_type_find("VipsOperation", "jpegsave_buffer");
}
#if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
if (t == HEIF) {
return vips_type_find("VipsOperation", "heifsave_buffer");
}
#endif
return 0;
}
@ -324,6 +337,20 @@ vips_tiffsave_bridge(VipsImage *in, void **buf, size_t *len) {
#endif
}
int
vips_heifsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int quality, int lossless) {
#if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
return vips_heifsave_buffer(in, buf, len,
"strip", INT_TO_GBOOLEAN(strip),
"Q", quality,
"lossless", INT_TO_GBOOLEAN(lossless),
NULL
);
#else
return 0;
#endif
}
int
vips_is_16bit (VipsInterpretation interpretation) {
return interpretation == VIPS_INTERPRETATION_RGB16 || interpretation == VIPS_INTERPRETATION_GREY16;
@ -370,6 +397,10 @@ vips_init_image (void *buf, size_t len, int imageType, VipsImage **out) {
#endif
} else if (imageType == MAGICK) {
code = vips_magickload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
#endif
#if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 8))
} else if (imageType == HEIF) {
code = vips_heifload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
#endif
}