mirror of
				https://github.com/imgproxy/imgproxy.git
				synced 2025-10-30 23:08:02 +02:00 
			
		
		
		
	Improved ICC profiles handling
This commit is contained in:
		| @@ -1,6 +1,9 @@ | ||||
| # Changelog | ||||
|  | ||||
| ## [Unreleased] | ||||
| ### Change | ||||
| - Improved ICC profiles handling. | ||||
|  | ||||
| ### Fix | ||||
| - (pro) Fix parsing metadata of extended sequential JPEGs. | ||||
|  | ||||
|   | ||||
| @@ -31,10 +31,6 @@ func exportColorProfile(pctx *pipelineContext, img *vips.Image, po *options.Proc | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if err := img.RgbColourspace(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if !keepProfile { | ||||
| 		return img.RemoveColourProfile() | ||||
| 	} | ||||
|   | ||||
| @@ -7,14 +7,6 @@ import ( | ||||
| ) | ||||
|  | ||||
| func finalize(pctx *pipelineContext, img *vips.Image, po *options.ProcessingOptions, imgdata *imagedata.ImageData) error { | ||||
| 	if err := img.RgbColourspace(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := img.CastUchar(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if po.StripMetadata { | ||||
| 		if err := img.Strip(); err != nil { | ||||
| 			return err | ||||
|   | ||||
| @@ -14,7 +14,7 @@ func importColorProfile(pctx *pipelineContext, img *vips.Image, po *options.Proc | ||||
|  | ||||
| 	convertToLinear := config.UseLinearColorspace && (pctx.wscale != 1 || pctx.hscale != 1) | ||||
|  | ||||
| 	if convertToLinear { | ||||
| 	if convertToLinear || img.IsCMYK() { | ||||
| 		if err := img.ImportColourProfile(); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|   | ||||
| @@ -27,12 +27,12 @@ var mainPipeline = pipeline{ | ||||
| 	rotateAndFlip, | ||||
| 	crop, | ||||
| 	fixWebpSize, | ||||
| 	exportColorProfile, | ||||
| 	applyFilters, | ||||
| 	extend, | ||||
| 	padding, | ||||
| 	flatten, | ||||
| 	watermark, | ||||
| 	exportColorProfile, | ||||
| 	finalize, | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,6 @@ var watermarkPipeline = pipeline{ | ||||
| 	importColorProfile, | ||||
| 	scale, | ||||
| 	rotateAndFlip, | ||||
| 	exportColorProfile, | ||||
| 	finalize, | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										18
									
								
								vips/vips.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								vips/vips.c
									
									
									
									
									
								
							| @@ -293,22 +293,22 @@ vips_has_embedded_icc(VipsImage *in) { | ||||
|  | ||||
| int | ||||
| vips_icc_import_go(VipsImage *in, VipsImage **out) { | ||||
|   return vips_icc_import(in, out, "embedded", TRUE, "pcs", VIPS_PCS_XYZ, NULL); | ||||
|   return vips_icc_import(in, out, "embedded", TRUE, "pcs", VIPS_PCS_LAB, NULL); | ||||
| } | ||||
|  | ||||
| int | ||||
| vips_icc_export_go(VipsImage *in, VipsImage **out) { | ||||
|   return vips_icc_export(in, out, NULL); | ||||
|   return vips_icc_export(in, out, "pcs", VIPS_PCS_LAB, NULL); | ||||
| } | ||||
|  | ||||
| int | ||||
| vips_icc_export_srgb(VipsImage *in, VipsImage **out) { | ||||
|   return vips_icc_export(in, out, "output_profile", "sRGB", NULL); | ||||
|   return vips_icc_export(in, out, "output_profile", "sRGB", "pcs", VIPS_PCS_LAB, NULL); | ||||
| } | ||||
|  | ||||
| int | ||||
| vips_icc_transform_go(VipsImage *in, VipsImage **out) { | ||||
|   return vips_icc_transform(in, out, "sRGB", "embedded", TRUE, "pcs", VIPS_PCS_XYZ, NULL); | ||||
|   return vips_icc_transform(in, out, "sRGB", "embedded", TRUE, "pcs", VIPS_PCS_LAB, NULL); | ||||
| } | ||||
|  | ||||
| int | ||||
| @@ -456,15 +456,13 @@ vips_replicate_go(VipsImage *in, VipsImage **out, int width, int height) { | ||||
|  | ||||
| int | ||||
| vips_embed_go(VipsImage *in, VipsImage **out, int x, int y, int width, int height) { | ||||
|   VipsImage *base = vips_image_new(); | ||||
| 	VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 2); | ||||
|   VipsImage *tmp; | ||||
|  | ||||
|   int ret = | ||||
|     vips_colourspace(in, &t[0], VIPS_INTERPRETATION_sRGB, NULL) || | ||||
|     vips_ensure_alpha(t[0], &t[1]) || | ||||
|     vips_embed(t[1], out, x, y, width, height, "extend", VIPS_EXTEND_BLACK, NULL); | ||||
|     vips_ensure_alpha(in, &tmp) || | ||||
|     vips_embed(tmp, out, x, y, width, height, "extend", VIPS_EXTEND_BLACK, NULL); | ||||
|  | ||||
|   clear_image(&base); | ||||
|   clear_image(&tmp); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
|   | ||||
| @@ -573,6 +573,10 @@ func (img *Image) Sharpen(sigma float32) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (img *Image) IsCMYK() bool { | ||||
| 	return C.vips_image_guess_interpretation(img.VipsImage) == C.VIPS_INTERPRETATION_CMYK | ||||
| } | ||||
|  | ||||
| func (img *Image) ImportColourProfile() error { | ||||
| 	var tmp *C.VipsImage | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user