Skip to content

SVG version often rasterized with gaps #197

@tobast

Description

@tobast

Hello,

I've noticed that although the SVGs generated by qrencode seem quite reasonable, a large variety of programs/libraries displaying those rasterize them with gaps between the qrcode "squares" (I'm unsure about the correct terminology, I'll refer to the little dark blocks as the qrcode squares). You can find examples of this behaviour at the end of the report.

Arguably, the error lies with the SVG rasterizers, and is out of the scope of qrencode, since the svg produced is quite reasonable. However, it seems that this issue has been lying for a very long time and is probably not going to be fixed everywhere any time soon. In the meantime, this makes qrencode --type SVG pretty much useless, since the output won't be reliably displayed nicely.

Proposed patch

I gave the issue a bit of thought, and although this doesn't seem completely satisfying (it looks way too much like duct tape), I believe that the best course would be to add a border to every square of eg. 5% of the square's size. From the limited experiments I made, it seems to fix the problem (at least on the few programs I tried), doesn't seem visually awkward, and doesn't prevent qrcode scanners to read the qrcode (again, very limited experiments so far).

If the fix seems reasonable to you, I could submit a PR.

Examples

I rendered a qrcode holding the string "foobar" for demo purposes, with qrencode 4.1.1, using the command qrencode --type SVG --background ffffff00 "foobar". Here are screenshots of a few applications rendering it badly:

Eog (Eye of Gnome), common software to display images:
eog

Inkscape (svg editor):
inkscape

After creating a PDF embedding the SVG qrcode with Inkscape,

Zathura, using the pdf backend mupdf:
mupdf

Firefox, using the pdf backend pdfjs:
pdfjs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions