diff options
| author | Viatrix | 2026-03-12 14:53:01 -0700 |
|---|---|---|
| committer | Viatrix | 2026-03-12 14:53:01 -0700 |
| commit | 5aca421003b008e116c170d6be789ac28e602cf7 (patch) | |
| tree | cc9eb6eddf778f2dfafbf8e09a370fd77b753cf2 | |
| parent | e475a7d88c9cc4128852a431dfe1977e426e4efc (diff) | |
Images with dummy fill and stroke handled correctly.
| -rw-r--r-- | imagemap.py | 6 | ||||
| -rw-r--r-- | tests/data/svg/image.svg | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/imagemap.py b/imagemap.py index 3d25403..8ab6558 100644 --- a/imagemap.py +++ b/imagemap.py @@ -62,10 +62,12 @@ class ImageMap(inkex.OutputExtension): link={attr:AREA_ATTRS[attr](a) for attr in AREA_ATTRS.keys()} for el in a.iterdescendants(): # CSS is preserved when flattening (for paths) if not isinstance(el,inkex.ShapeElement): continue - if el.tag=='{http://www.w3.org/2000/svg}image': - el.tag='{http://www.w3.org/2000/svg}rect' # because flattening an image creates a clip-path style=el.effective_style() style[CSS_LINK_INDEX]=f'" {CSS_LINK_INDEX}-{len(links)} "' + if el.tag=='{http://www.w3.org/2000/svg}image': + el.tag='{http://www.w3.org/2000/svg}rect' # because flattening an image creates a clip-path + style['stroke']='none' + style['fill']='#000' links += [link] if len(links)==0: raise inkex.AbortExtension(_("Image has no hyperlinks.\nAdd a hyperlink to an object with right-click → \"{}\".").format(_("Create Anchor (Hyperlink)"))) diff --git a/tests/data/svg/image.svg b/tests/data/svg/image.svg index e0d62d4..9b970f7 100644 --- a/tests/data/svg/image.svg +++ b/tests/data/svg/image.svg @@ -1,6 +1,6 @@ <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- Transparent areas of the image should remain part of the link. --> <a xlink:href="http://example.com"> - <image x="25" y="25" width="50" height="50" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADUlEQVR42mMAgv9gBAAJAQH/66EXCgAAAABJRU5ErkJggg==" image-rendering="optimizeSpeed"/> + <image x="25" y="25" width="50" height="50" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADUlEQVR42mMAgv9gBAAJAQH/66EXCgAAAABJRU5ErkJggg==" image-rendering="optimizeSpeed" stroke="red" fill="none"/> </a> </svg> |
