Skip to content

Commit c9a61b3

Browse files
committed
✨ Use resvg instead of magick for svg thumbnailing
1 parent 4219f77 commit c9a61b3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

thumbnails.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func (ctx *RunContext) MakeThumbnail(media Media, targetSize int, saveTo string)
4242
return ctx.makeGifThumbnail(media, targetSize, saveTo)
4343
}
4444

45+
if media.ContentType == "image/svg+xml" {
46+
return ctx.makeSvgThumbnail(media, targetSize, saveTo)
47+
}
48+
4549
if strings.HasPrefix(media.ContentType, "image/") {
4650
return run("magick", media.DistSource.Absolute(ctx), "-resize", fmt.Sprint(targetSize), saveTo)
4751
}
@@ -58,6 +62,11 @@ func (ctx *RunContext) MakeThumbnail(media Media, targetSize int, saveTo string)
5862

5963
}
6064

65+
func (ctx *RunContext) makeSvgThumbnail(media Media, targetSize int, saveTo string) error {
66+
// Use resvg instead of magick, because magick delegates to inkscape which is not reliable in parallel (see https://gitlab.com/inkscape/inkscape/-/issues/4716)
67+
return run("resvg", "--width", fmt.Sprint(targetSize), "--height", fmt.Sprint(targetSize), media.DistSource.Absolute(ctx), saveTo)
68+
}
69+
6170
func (ctx *RunContext) makePdfThumbnail(media Media, targetSize int, saveTo string) error {
6271
// If the target extension was not supported, convert from png to the actual target extension
6372
temporaryPng, err := ioutil.TempFile("", "*.png")

0 commit comments

Comments
 (0)