svg image support

47 views
Skip to first unread message

Quinn

unread,
May 19, 2025, 9:01:54 AMMay 19
to Perkeep
Hi, i have a PR that adds webp support:

https://github.com/perkeep/perkeep/pull/1695

When working on this i found i have some cover images (used in camliContentImage) that are actually SVGs, so it would be nice for me if there was a way to treat SVGs as if they were regular images within perkeep. this isn't nearly as well supported as webp of course, i found this library which uses the go image system:

https://github.com/gen2brain/svg/blob/main/decode.go

This adds a lot of code in dependencies. Instead of this, I was thinking I could also add something that checks if you have a "convert" command available and shells out to that, otherwise just fails silently. So just works like it currently does, or will rasterize the image if you have imagemagick commands in your PATH.

I'd like to do something here, would be nice to be able to preview SVGs the same way I can with other images.

Quinn

Ivan Vučica

unread,
May 19, 2025, 11:39:12 AMMay 19
to per...@googlegroups.com, Perkeep
Why rasterize SVGs? Unless an SVG is overly complex, it’s easier to just pass it in src attribute as-is, and just override width and height as needed, no?

On 19 May 2025, at 14:02, Quinn <q.sha...@gmail.com> wrote:

Hi, i have a PR that adds webp support:
--
You received this message because you are subscribed to the Google Groups "Perkeep" group.
To unsubscribe from this group and stop receiving emails from it, send an email to perkeep+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/perkeep/136ef0b9-8935-40d5-8896-3a8ff5a7f669n%40googlegroups.com.

Quinn

unread,
May 19, 2025, 12:22:20 PMMay 19
to Perkeep
definitely, I'm just trying to slot it in to the existing workflow for how image previews are handled, with minimal changes. The js code is harder to understand than the go code, for me at least. I'm happy to try that approach instead, if it seems like a more merge-able contribution.

Quinn

unread,
May 19, 2025, 8:54:34 PMMay 19
to Perkeep
OK, I hacked a pathway for the thumbnail endpoint (ui/thumbnail/ref) to send the svg file data directly without attempting to resize it:


This allows SVGs to be used as image thumbnails for permanodes, without having to parse them as images using the golang `image` package. Would love to get feedback on this PR!
Reply all
Reply to author
Forward
0 new messages