diff --git a/vips.c b/vips.c index 4780d9a4..6d27693e 100644 --- a/vips.c +++ b/vips.c @@ -1,6 +1,5 @@ #include "vips.h" #include -#include #define VIPS_SUPPORT_ARRAY_HEADERS \ (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION >= 9)) @@ -539,7 +538,10 @@ vips_pngsave_go(VipsImage *in, void **buf, size_t *len, int interlace, int quant NULL ); - int bitdepth = ceil(log2(colors)); + int bitdepth = 1; + if (colors > 16) bitdepth = 8; + else if (colors > 4) bitdepth = 4; + else if (colors > 2) bitdepth = 2; return vips_pngsave_buffer( in, buf, len, diff --git a/vips.go b/vips.go index acc3eda1..b814834d 100644 --- a/vips.go +++ b/vips.go @@ -2,7 +2,7 @@ package main /* #cgo pkg-config: vips -#cgo LDFLAGS: -s -w -lm +#cgo LDFLAGS: -s -w #cgo CFLAGS: -O3 #include "vips.h" */