mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
feat: allow to remove ICC profile metadata
This commit is contained in:
parent
941b15cd9a
commit
5d322714ec
5 changed files with 30 additions and 2 deletions
8
vips.go
8
vips.go
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue