Workers: watermark images hosted on Cloudflare Images
We're trying to apply a watermark with a simple worker script. Code is taken from documentation. It seems that worker's fetch method completely ignores cf.image options. It just returns original image without any modification.
It seems a lot of people have this problem. Is it even possible to apply a watermark to an image hosted on Cloudflare Images?
Without this feature we would have to store twice the amount of images, and it's a no-go for us.
Worker code for reference:
3 Replies
facing the same problem now
you got it working?
hey there —
currently, the
draw
options are supported only for transformations (remote images), but we recently released an Images binding which you can use as a workaround:
https://developers.cloudflare.com/images/transform-images/bindings/
https://developers.cloudflare.com/images/transform-images/draw-overlays/#draw-using-the-images-bindingCloudflare Docs
Bind to Workers API · Cloudflare Images docs
A binding connects your Worker to external resources on the Developer Platform, like Images, R2 buckets, or KV Namespaces.
Cloudflare Docs
Draw overlays and watermarks · Cloudflare Images docs
You can draw additional images on top of a resized image, with transparency and blending effects. This enables adding of watermarks, logos, signatures, vignettes, and other effects to resized images.
curious about both of your use cases. are you looking to watermark on upload or on delivery? if the latter, if we provided a way to define a watermark in a predefined variant, would that meet your use case?