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

Inline data URIs for SVG markers are not directly supported in QGIS 3.40.x #59575

Open
2 tasks done
cxcandid opened this issue Nov 24, 2024 · 3 comments · May be fixed by #59589
Open
2 tasks done

Inline data URIs for SVG markers are not directly supported in QGIS 3.40.x #59575

cxcandid opened this issue Nov 24, 2024 · 3 comments · May be fixed by #59589
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@cxcandid
Copy link

cxcandid commented Nov 24, 2024

What is the bug or the crash?

In Sept. 2020 I found out that we can use inline SVG definitions to define a point marker symbol in QGIS: https://gis.stackexchange.com/questions/374223/using-embedded-svg-symbol-in-multiple-layers

In QGIS 3.36.x it was possible to enter the following data URI in Expression Builder to define a SVG marker:

'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px"><path fill="param(fill) #000000" d="M50,2.5c-19.2,0-34.8,15-34.8,33.4C15.2,61.3,50,97.5,50,97.5s34.8-36.2,34.8-61.6 C84.8,17.5,69.2,2.5,50,2.5z M50,48.2c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9c7.1,0,12.9,5.8,12.9,12.9 C62.9,42.4,57.1,48.2,50,48.2z"/></svg>'

Unfortunately, this no longer works in QGIS 3.40.x.

In QGIS 3.40.x we also need to convert the data URI to base64 to achieve the same effect:

'base64:'|| to_base64('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px"><path fill="param(fill) #000000" d="M50,2.5c-19.2,0-34.8,15-34.8,33.4C15.2,61.3,50,97.5,50,97.5s34.8-36.2,34.8-61.6 C84.8,17.5,69.2,2.5,50,2.5z M50,48.2c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9c7.1,0,12.9,5.8,12.9,12.9 C62.9,42.4,57.1,48.2,50,48.2z"/></svg>')

QGIS 3.40.x can no longer process inline data URIs for SVG markers directly.

Steps to reproduce the issue

See bug report.

Versions

QGIS 3.40.x Windows

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@cxcandid cxcandid added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Nov 24, 2024
@nyalldawson nyalldawson self-assigned this Nov 26, 2024
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Nov 26, 2024
@nyalldawson nyalldawson linked a pull request Nov 26, 2024 that will close this issue
@nyalldawson
Copy link
Collaborator

Thanks for reporting this!

It's funny, inline data like this was never formally supported -- it was a happy accident that it worked at all. Anyway, I've fixed it in #59589 and added tests, so you can consider if officially supported now.

@cxcandid
Copy link
Author

@nyalldawson many thanks for your support!

Is this a general fix that works everywhere where SVG symbols can be selected (i.e. label background)?

@nyalldawson
Copy link
Collaborator

@cxcandid yes, it'll work everywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants