mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
Merge pull request #299 from evanoberholster/master
Update Transform ICC Profiles with Input Profile
This commit is contained in:
commit
1faf8e4f8d
4 changed files with 44 additions and 2 deletions
|
|
@ -224,4 +224,5 @@ type Options struct {
|
||||||
Threshold float64
|
Threshold float64
|
||||||
Gamma float64
|
Gamma float64
|
||||||
OutputICC string
|
OutputICC string
|
||||||
|
InputICC string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ func saveImage(image *C.VipsImage, o Options) ([]byte, error) {
|
||||||
Interlace: o.Interlace,
|
Interlace: o.Interlace,
|
||||||
NoProfile: o.NoProfile,
|
NoProfile: o.NoProfile,
|
||||||
Interpretation: o.Interpretation,
|
Interpretation: o.Interpretation,
|
||||||
|
InputICC: o.InputICC,
|
||||||
OutputICC: o.OutputICC,
|
OutputICC: o.OutputICC,
|
||||||
StripMetadata: o.StripMetadata,
|
StripMetadata: o.StripMetadata,
|
||||||
Lossless: o.Lossless,
|
Lossless: o.Lossless,
|
||||||
|
|
|
||||||
35
vips.go
35
vips.go
|
|
@ -52,6 +52,7 @@ type vipsSaveOptions struct {
|
||||||
NoProfile bool
|
NoProfile bool
|
||||||
StripMetadata bool
|
StripMetadata bool
|
||||||
Lossless bool
|
Lossless bool
|
||||||
|
InputICC string // Absolute path to the input ICC profile
|
||||||
OutputICC string // Absolute path to the output ICC profile
|
OutputICC string // Absolute path to the output ICC profile
|
||||||
Interpretation Interpretation
|
Interpretation Interpretation
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +240,7 @@ func vipsRotate(image *C.VipsImage, angle Angle) (*C.VipsImage, error) {
|
||||||
var out *C.VipsImage
|
var out *C.VipsImage
|
||||||
defer C.g_object_unref(C.gpointer(image))
|
defer C.g_object_unref(C.gpointer(image))
|
||||||
|
|
||||||
err := C.vips_rotate_bimg(image, &out, C.int(angle))
|
err := C.vips_rotate_bridge(image, &out, C.int(angle))
|
||||||
if err != 0 {
|
if err != 0 {
|
||||||
return nil, catchVipsError()
|
return nil, catchVipsError()
|
||||||
}
|
}
|
||||||
|
|
@ -247,6 +248,23 @@ func vipsRotate(image *C.VipsImage, angle Angle) (*C.VipsImage, error) {
|
||||||
return out, nil
|
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) {
|
func vipsFlip(image *C.VipsImage, direction Direction) (*C.VipsImage, error) {
|
||||||
var out *C.VipsImage
|
var out *C.VipsImage
|
||||||
defer C.g_object_unref(C.gpointer(image))
|
defer C.g_object_unref(C.gpointer(image))
|
||||||
|
|
@ -387,6 +405,21 @@ func vipsPreSave(image *C.VipsImage, o *vipsSaveOptions) (*C.VipsImage, error) {
|
||||||
image = outImage
|
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) {
|
if o.OutputICC != "" && vipsHasProfile(image) {
|
||||||
outputIccPath := C.CString(o.OutputICC)
|
outputIccPath := C.CString(o.OutputICC)
|
||||||
defer C.free(unsafe.Pointer(outputIccPath))
|
defer C.free(unsafe.Pointer(outputIccPath))
|
||||||
|
|
|
||||||
9
vips.h
9
vips.h
|
|
@ -188,7 +188,7 @@ vips_type_find_save_bridge(int t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips_rotate_bimg(VipsImage *in, VipsImage **out, int angle) {
|
vips_rotate_bridge(VipsImage *in, VipsImage **out, int angle) {
|
||||||
int rotate = VIPS_ANGLE_D0;
|
int rotate = VIPS_ANGLE_D0;
|
||||||
|
|
||||||
angle %= 360;
|
angle %= 360;
|
||||||
|
|
@ -290,6 +290,13 @@ vips_icc_transform_bridge (VipsImage *in, VipsImage **out, const char *output_ic
|
||||||
return vips_icc_transform(in, out, output_icc_profile, "embedded", TRUE, NULL);
|
return vips_icc_transform(in, out, output_icc_profile, "embedded", TRUE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
vips_icc_transform_with_default_bridge (VipsImage *in, VipsImage **out, const char *output_icc_profile, const char *input_icc_profile) {
|
||||||
|
// `output_icc_profile` represents the absolute path to the output ICC profile file
|
||||||
|
return vips_icc_transform(in, out, output_icc_profile, "input_profile", input_icc_profile, "embedded", FALSE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips_jpegsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int quality, int interlace) {
|
vips_jpegsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int quality, int interlace) {
|
||||||
return vips_jpegsave_buffer(in, buf, len,
|
return vips_jpegsave_buffer(in, buf, len,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue