示例#1
0
func srgb(image *vips.Image) error {
	// Transform from embedded ICC profile if present or default profile
	// if CMYK.  Ignore errors.
	if image.ImageFieldExists(vips.MetaIccName) {
		_ = image.IccTransform(sRgbFile, "", vips.IntentRelative)
	} else if image.ImageGuessInterpretation() == vips.InterpretationCMYK {
		_ = image.IccTransform(sRgbFile, cmykFile, vips.IntentRelative)
	}

	space := image.ImageGuessInterpretation()
	if space != vips.InterpretationSRGB && space != vips.InterpretationBW {
		if err := image.Colourspace(vips.InterpretationSRGB); err != nil {
			return err
		}
	}

	return nil
}