From 896c479f95fec41a26c9f1119a600c9a63ea10fd Mon Sep 17 00:00:00 2001 From: Yoan Blanc Date: Mon, 11 Sep 2017 10:00:06 -0400 Subject: [PATCH] Fix typo and small cleanup. - it addresses the comments for ab4ef56bab7ca2f283b61a69f5bdf6784f1baadf Signed-off-by: Yoan Blanc --- vips.go | 2 +- vips.h | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/vips.go b/vips.go index 5c54e1e..5843df2 100644 --- a/vips.go +++ b/vips.go @@ -421,7 +421,7 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) { saveErr := C.int(0) interlace := C.int(boolToInt(o.Interlace)) quality := C.int(o.Quality) - strip := C.int(boolToInt(o.Interlace)) + strip := C.int(boolToInt(o.StripMetadata)) if o.Type != 0 && !IsTypeSupportedSave(o.Type) { return nil, fmt.Errorf("VIPS cannot save to %#v", ImageTypes[o.Type]) diff --git a/vips.h b/vips.h index 28c2361..30e6847 100644 --- a/vips.h +++ b/vips.h @@ -20,6 +20,9 @@ #define EXIF_IFD0_ORIENTATION "exif-ifd0-Orientation" +#define INT_TO_GBOOLEAN(bool) (bool > 0 ? TRUE : FALSE) + + enum types { UNKNOWN = 0, JPEG, @@ -62,11 +65,6 @@ remove_profile(VipsImage *image) { vips_image_remove(image, VIPS_META_ICC_NAME); } -static gboolean -with_interlace(int interlace) { - return interlace > 0 ? TRUE : FALSE; -} - static int has_alpha_channel(VipsImage *image) { return ( @@ -274,10 +272,10 @@ vips_icc_transform_bridge (VipsImage *in, VipsImage **out, const char *output_ic int vips_jpegsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int quality, int interlace) { return vips_jpegsave_buffer(in, buf, len, - "strip", strip == 1 ? TRUE : FALSE, + "strip", INT_TO_GBOOLEAN(strip), "Q", quality, "optimize_coding", TRUE, - "interlace", with_interlace(interlace), + "interlace", INT_TO_GBOOLEAN(interlace), NULL ); } @@ -286,17 +284,17 @@ int vips_pngsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int compression, int quality, int interlace) { #if (VIPS_MAJOR_VERSION >= 8 || (VIPS_MAJOR_VERSION >= 7 && VIPS_MINOR_VERSION >= 42)) return vips_pngsave_buffer(in, buf, len, - "strip", strip == 1 ? TRUE : FALSE, + "strip", INT_TO_GBOOLEAN(strip), "compression", compression, - "interlace", with_interlace(interlace), + "interlace", INT_TO_GBOOLEAN(interlace), "filter", VIPS_FOREIGN_PNG_FILTER_NONE, NULL ); #else return vips_pngsave_buffer(in, buf, len, - "strip", strip == 1 ? TRUE : FALSE, + "strip", INT_TO_GBOOLEAN(strip), "compression", compression, - "interlace", with_interlace(interlace), + "interlace", INT_TO_GBOOLEAN(interlace), NULL ); #endif @@ -305,7 +303,7 @@ vips_pngsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int compr int vips_webpsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int quality) { return vips_webpsave_buffer(in, buf, len, - "strip", strip == 1 ? TRUE : FALSE, + "strip", INT_TO_GBOOLEAN(strip), "Q", quality, NULL );