diff --git a/CHANGELOG.md b/CHANGELOG.md index 61c20f2a..78825dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fix - Fix crashes in cases where the `max_bytes` processing option was used and image saving failed. - Fix error when using the `extend` or `extend_aspect_ratio` processing option while setting zero width or height. +- Fix color loss when applying a watermark with a palette on an image without a palette. - (pro) Fix crashes when using `IMGPROXY_SMART_CROP_FACE_DETECTION` with large `IMGPROXY_CONCURRENCY`. - (pro) Fix watermark scaling when neither watermark scale nor watermark size is specified. diff --git a/processing/watermark.go b/processing/watermark.go index 518e5234..a92b7656 100644 --- a/processing/watermark.go +++ b/processing/watermark.go @@ -18,6 +18,7 @@ var watermarkPipeline = pipeline{ scale, rotateAndFlip, padding, + stripMetadata, } func prepareWatermark(wm *vips.Image, wmData *imagedata.ImageData, opts *options.WatermarkOptions, imgWidth, imgHeight int, offsetScale float64, framesCount int) error { @@ -30,6 +31,8 @@ func prepareWatermark(wm *vips.Image, wmData *imagedata.ImageData, opts *options po.Dpr = 1 po.Enlarge = true po.Format = wmData.Type + po.StripMetadata = true + po.KeepCopyright = false if opts.Scale > 0 { po.Width = imath.Max(imath.ScaleToEven(imgWidth, opts.Scale), 1) @@ -77,6 +80,8 @@ func prepareWatermark(wm *vips.Image, wmData *imagedata.ImageData, opts *options } } + wm.RemoveHeader("palette-bit-depth") + return nil } diff --git a/vips/vips.go b/vips/vips.go index 1d837088..0c44f1cd 100644 --- a/vips/vips.go +++ b/vips/vips.go @@ -484,6 +484,10 @@ func (img *Image) SetBlob(name string, value []byte) { C.vips_image_set_blob_copy(img.VipsImage, cachedCString(name), unsafe.Pointer(&value[0]), C.size_t(len(value))) } +func (img *Image) RemoveHeader(name string) { + C.vips_image_remove(img.VipsImage, cachedCString(name)) +} + func (img *Image) CastUchar() error { var tmp *C.VipsImage