mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
Update Transform ICC Profiles with Input Profile
Support for input profile when there is none embbeded in image.
This commit is contained in:
parent
4eb8362deb
commit
d883bb6fee
4 changed files with 44 additions and 2 deletions
35
vips.go
35
vips.go
|
|
@ -52,6 +52,7 @@ type vipsSaveOptions struct {
|
|||
NoProfile bool
|
||||
StripMetadata bool
|
||||
Lossless bool
|
||||
InputICC string // Absolute path to the input ICC profile
|
||||
OutputICC string // Absolute path to the output ICC profile
|
||||
Interpretation Interpretation
|
||||
}
|
||||
|
|
@ -233,7 +234,7 @@ func vipsRotate(image *C.VipsImage, angle Angle) (*C.VipsImage, error) {
|
|||
var out *C.VipsImage
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
|
||||
err := C.vips_rotate(image, &out, C.int(angle))
|
||||
err := C.vips_rotate_bridge(image, &out, C.int(angle))
|
||||
if err != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
|
|
@ -241,6 +242,23 @@ func vipsRotate(image *C.VipsImage, angle Angle) (*C.VipsImage, error) {
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func vipsTransformICC(image *C.VipsImage, inputICC string, outputICC string) (*C.VipsImage, error) {
|
||||
var out *C.VipsImage
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
|
||||
outputIccPath := C.CString(outputICC)
|
||||
defer C.free(unsafe.Pointer(outputIccPath))
|
||||
inputIccPath := C.CString(inputICC)
|
||||
defer C.free(unsafe.Pointer(inputIccPath))
|
||||
err := C.vips_icc_transform_with_default_bridge(image, &out, outputIccPath, inputIccPath)
|
||||
//err := C.vips_icc_transform_bridge2(image, &outImage, outputIccPath, inputIccPath)
|
||||
if int(err) != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func vipsFlip(image *C.VipsImage, direction Direction) (*C.VipsImage, error) {
|
||||
var out *C.VipsImage
|
||||
defer C.g_object_unref(C.gpointer(image))
|
||||
|
|
@ -381,6 +399,21 @@ func vipsPreSave(image *C.VipsImage, o *vipsSaveOptions) (*C.VipsImage, error) {
|
|||
image = outImage
|
||||
}
|
||||
|
||||
if o.OutputICC != "" && o.InputICC != "" {
|
||||
outputIccPath := C.CString(o.OutputICC)
|
||||
defer C.free(unsafe.Pointer(outputIccPath))
|
||||
|
||||
inputIccPath := C.CString(o.InputICC)
|
||||
defer C.free(unsafe.Pointer(inputIccPath))
|
||||
|
||||
err := C.vips_icc_transform_with_default_bridge(image, &outImage, outputIccPath, inputIccPath)
|
||||
if int(err) != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
C.g_object_unref(C.gpointer(image))
|
||||
return outImage, nil
|
||||
}
|
||||
|
||||
if o.OutputICC != "" && vipsHasProfile(image) {
|
||||
outputIccPath := C.CString(o.OutputICC)
|
||||
defer C.free(unsafe.Pointer(outputIccPath))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue