1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-03 10:43:58 +02:00

Strip watermark meta and remove its palette depth

This commit is contained in:
DarthSim 2023-04-26 18:24:20 +03:00
parent 954378c0a6
commit 723666ea1a
3 changed files with 10 additions and 0 deletions

View File

@ -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.

View File

@ -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
}

View File

@ -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