Exception "The SVG size is undefined" raised using svg2png
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- computer-graphics
Research direction
Start with the provided Python script and SVG URL, reproducing the failure through cairosvg.svg2png. Trace the reported path in cairosvg/surface.py around SVGSurface and mask handling, then add a regression test for this input; done means the SVG converts to PNG without the reported exception.
Written by the indexing model from the issue text.
Description
Converting the following SVG file (see code bellow) into a PNG caused an exception to be raised:
Traceback (most recent call last):
File "/Volumes/Test/main.py", line 12, in <module>
cairosvg.svg2png(url=URL, write_to=OUTPUT_PATH)
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/__init__.py", line 55, in svg2png
return surface.PNGSurface.convert(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/surface.py", line 133, in convert
instance = cls(
^^^^
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/surface.py", line 225, in __init__
self.draw(tree)
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/surface.py", line 472, in draw
self.draw(child)
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/surface.py", line 472, in draw
self.draw(child)
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/surface.py", line 480, in draw
paint_mask(self, node, mask, opacity)
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/defs.py", line 145, in paint_mask
mask_surface = SVGSurface(mask_node, None, surface.dpi, surface)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Volumes/Test/venv/lib/python3.12/site-packages/cairosvg/surface.py", line 209, in __init__
raise ValueError('The SVG size is undefined')
ValueError: The SVG size is undefined
Here is the code to reproduce:
import cairosvg
URL = "https://upload.wikimedia.org/wikipedia/commons/3/32/Saltwater_Limpet_Diagram-en.svg"
OUTPUT_PATH = "output.png"
cairosvg.svg2png(url=URL, write_to=OUTPUT_PATH)
- Dominant language
- Python
- Stars
- 959
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Kozea/CairoSVG
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
并发下的渲染表现Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
feature
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
future-agi/future-agi#5908 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
eclipse-score/coverage_tool#101 ·
Maintainers usually reply within 2 days
-
Placeholder export disables HTML image input for picture descriptionPossibly taken @cloudiful claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
docling-project/docling-serve#817 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Techiebutler/freeframe#687 ·
Maintainers usually reply within 1 day
-
Parse truncated verbose GC logs up to the first XML errorPossibly taken A pull request linked to this issue is open or already merged. Openbug verbose GC
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
IBM/javacore-analyser#677 ·
Maintainers usually reply within 1 day