Skip to content

Add optional image watermark transforms - #503

Open
mariojfduarte wants to merge 2 commits into
willnorris:mainfrom
mariojfduarte:feature/watermark
Open

mariojfduarte wants to merge 2 commits into
willnorris:mainfrom
mariojfduarte:feature/watermark

Conversation

@mariojfduarte

@mariojfduarte mariojfduarte commented Aug 3, 2026 •

Copy link
Copy Markdown

Summary

  • Adds watermark options (wmurl, wmp, wmo, wms, wmx, wmy) that overlay a remote image after resize/rotate/flip
  • Watermark URL is URL-safe base64 in wmurl so it fits the existing /{options}/{remote_url} path shape
  • Watermark is fetched via the caching HTTP client. A failed fetch still returns the transformed base image. The watermark host must pass the proxy allow and deny lists, and a signature does not add hosts. On a signature-only proxy the signature must cover the options, so a URL-only signature cannot be reused with a different wmurl
  • wmo0 is fully transparent and wms0 draws nothing
  • Includes parse, overlay, and host-policy tests, plus README notes

Test plan

  • go test ./...
  • Run locally and request e.g. /800x,wmurlaHR0cHM6Ly9leGFtcGxlLmNvbS9sb2dvLnBuZw,wmpse,wmo0.5,wms0.2/https://example.com/photo.jpg
  • Confirm position variants (wmpc, wmpnw, wmpse) and opacity/scale/padding behave as documented
  • Confirm missing/unreachable watermark URL still returns the transformed base image
  • Confirm a watermark host outside the allow list, or on the deny list, is rejected
  • Confirm wmo0 leaves the image unchanged and wms0 draws nothing

@alex-vebiko

Copy link
Copy Markdown

This feature seems to be very useful for use-cases in our company. @willnorris What do you think of adding this to the service? Or it's kind of overkill for basic processing?

mariojfduarte and others added 2 commits October 27, 2026 19:13
Allow overlaying a remote watermark image via wmurl/wmp/wmo/wms/wmx/wmy
options so proxies can brand or mark images without a separate processing step.

Co-authored-by: Cursor <cursoragent@cursor.com>
Apply the proxy allow and deny lists to wmurl, and require an options
signature on signature-only proxies so a URL-only signature cannot be
rewritten to fetch another host. Let wmo0 and wms0 mean zero.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mariojfduarte

Copy link
Copy Markdown
Author

@willnorris I rebased onto current main and tightened the fetch rules.

The options are ignored unless wmurl is present. The watermark host now has to pass the same allow and deny lists as the remote image, and a signature does not authorize extra watermark hosts. On a signature-only proxy, the signature has to cover the options, so a signature of the image URL alone cannot be rewritten with a different wmurl. A failed watermark fetch still returns the transformed image.

go test ./... passes. There is a production use case for this (see the comment above): branding images in the proxy instead of a separate processing step. Happy to adjust the API if you would rather keep the surface smaller.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants