Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support using data urls as watermarkurl #1276

Open
marcoreni opened this issue Apr 30, 2024 · 1 comment
Open

Feature request: support using data urls as watermarkurl #1276

marcoreni opened this issue Apr 30, 2024 · 1 comment

Comments

@marcoreni
Copy link

We're trying to add a watermark by composing an SVG dynamically and passing it to Imgproxy.

We're doing that by creating an <svg...> object, then creating a data url for the object and passing it, base64encoded, to the service. However we're encountering a Can't download watermark: Unknown scheme: data.

Here is the raw data:

data:image/svg+xml,%3Csvg width='514' height='290' viewBox='0 0 514 290' version='1.1' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0 0H514V290H0V0Z' fill='url(%23paint0_linear_11346_5504)'/%3E%3Cdefs%3E%3ClinearGradient id='paint0_linear_11346_5504' x1='74.0113' y1='256.089' x2='94.5366' y2='157.305' gradientUnits='userSpaceOnUse'%3E%3Cstop class='start' stop-opacity='0.8'/%3E%3Cstop class='stop' offset='1' stop-opacity='0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cstyle%3Estop %7B stop-color: red %7D%3C/style%3E%3C/svg%3E

Here is the same encoded data:

ZGF0YTppbWFnZS9zdmcreG1sLCUzQ3N2ZyB3aWR0aD0nNTE0JyBoZWlnaHQ9JzI5MCcgdmlld0JveD0nMCAwIDUxNCAyOTAnIHZlcnNpb249JzEuMScgZmlsbD0nbm9uZScgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyUzRSUzQ3BhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00wIDBINTE0VjI5MEgwVjBaJyBmaWxsPSd1cmwoJTIzcGFpbnQwX2xpbmVhcl8xMTM0Nl81NTA0KScvJTNFJTNDZGVmcyUzRSUzQ2xpbmVhckdyYWRpZW50IGlkPSdwYWludDBfbGluZWFyXzExMzQ2XzU1MDQnIHgxPSc3NC4wMTEzJyB5MT0nMjU2LjA4OScgeDI9Jzk0LjUzNjYnIHkyPScxNTcuMzA1JyBncmFkaWVudFVuaXRzPSd1c2VyU3BhY2VPblVzZSclM0UlM0NzdG9wIGNsYXNzPSdzdGFydCcgc3RvcC1vcGFjaXR5PScwLjgnLyUzRSUzQ3N0b3AgY2xhc3M9J3N0b3AnIG9mZnNldD0nMScgc3RvcC1vcGFjaXR5PScwJy8lM0UlM0MvbGluZWFyR3JhZGllbnQlM0UlM0MvZGVmcyUzRSUzQ3N0eWxlJTNFc3RvcCAlN0Igc3RvcC1jb2xvcjogcmVkICU3RCUzQy9zdHlsZSUzRSUzQy9zdmclM0U

Is there any way to support inline images?

@DarthSim
Copy link
Member

Using data URLs doesn't look like a good idea to me. Your example is a 700+ character long string, and you can easily exceed the browser's limit on the URL length with it.

If you generate those watermarks on the backend side, it's better to move the watermark generation to a separate endpoint and use it as a watermark URL.

If it's not an option, I can add a watermark_data option. It'd be simpler than adding data URLs support.

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

No branches or pull requests

2 participants