mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-08 15:08:16 -07:00
feat: save a RGB colorspace
This commit is contained in:
parent
e4f822b28c
commit
941b15cd9a
2 changed files with 14 additions and 3 deletions
11
vips.go
11
vips.go
|
|
@ -226,17 +226,22 @@ func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
|
|||
err := C.int(0)
|
||||
interlace := C.int(boolToInt(o.Interlace))
|
||||
|
||||
// Force RGB color space
|
||||
var outImage *C.struct__VipsImage
|
||||
C.vips_colourspace_bridge(image, &outImage)
|
||||
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
defer C.g_object_unref(C.gpointer(outImage))
|
||||
|
||||
switch o.Type {
|
||||
case PNG:
|
||||
err = C.vips_pngsave_bridge(image, &ptr, &length, 1, C.int(o.Compression), C.int(o.Quality), interlace)
|
||||
err = C.vips_pngsave_bridge(outImage, &ptr, &length, 1, C.int(o.Compression), C.int(o.Quality), interlace)
|
||||
break
|
||||
case WEBP:
|
||||
err = C.vips_webpsave_bridge(image, &ptr, &length, 1, C.int(o.Quality))
|
||||
err = C.vips_webpsave_bridge(outImage, &ptr, &length, 1, C.int(o.Quality))
|
||||
break
|
||||
default:
|
||||
err = C.vips_jpegsave_bridge(image, &ptr, &length, 1, C.int(o.Quality), interlace)
|
||||
err = C.vips_jpegsave_bridge(outImage, &ptr, &length, 1, C.int(o.Quality), interlace)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
|||
6
vips.h
6
vips.h
|
|
@ -129,6 +129,12 @@ vips_extract_area_bridge(VipsImage *in, VipsImage **out, int left, int top, int
|
|||
return vips_extract_area(in, out, left, top, width, height, NULL);
|
||||
};
|
||||
|
||||
int
|
||||
vips_colourspace_bridge(VipsImage *in, VipsImage **out)
|
||||
{
|
||||
return vips_colourspace(in, out, VIPS_INTERPRETATION_sRGB, NULL);
|
||||
};
|
||||
|
||||
gboolean
|
||||
with_interlace(int interlace) {
|
||||
return interlace > 0 ? TRUE : FALSE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue