feat: allow to remove ICC profile metadata

This commit is contained in:
Tomas Aparicio 2015-06-13 22:11:54 +01:00
parent 941b15cd9a
commit 5d322714ec
5 changed files with 30 additions and 2 deletions

View file

@ -36,6 +36,7 @@ type vipsSaveOptions struct {
Compression int
Type ImageType
Interlace bool
NoProfile bool
}
type vipsWatermarkOptions struct {
@ -221,11 +222,15 @@ func vipsRead(buf []byte) (*C.struct__VipsImage, ImageType, error) {
}
func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
var ptr unsafe.Pointer
length := C.size_t(0)
err := C.int(0)
interlace := C.int(boolToInt(o.Interlace))
// Remove ICC profile metadata
if o.NoProfile {
C.remove_profile(image)
}
// Force RGB color space
var outImage *C.struct__VipsImage
C.vips_colourspace_bridge(image, &outImage)
@ -233,6 +238,7 @@ func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
defer C.g_object_unref(C.gpointer(image))
defer C.g_object_unref(C.gpointer(outImage))
var ptr unsafe.Pointer
switch o.Type {
case PNG:
err = C.vips_pngsave_bridge(outImage, &ptr, &length, 1, C.int(o.Compression), C.int(o.Quality), interlace)