Skip to content

Commit 659239b

Browse files
committed
qubes.GetImageRGBA: fix SVG conversion for images without explicit dimensions
SVGs that specify dimensions only via viewBox (no explicit pixel width/height attributes) cause gm identify to return 0 for both width and height. Passing -w 0 -h 0 to rsvg-convert produces an empty or corrupt PNG, which then causes the second gm identify to fail with 'No decode delegate for this image format'. When gm identify returns zero or empty dimensions for an SVG, let rsvg-convert determine the natural size from the viewBox instead. The actual dimensions are then read from the resulting PNG by the existing gm identify call that follows. Fixes: QubesOS/qubes-issues#9145
1 parent 0a67a77 commit 659239b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

qubes-rpc/qubes.GetImageRGBA

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ h="$(echo "$s"|cut -d " " -f 2)"
2727
m="$(echo "$s"|cut -d " " -f 3)"
2828
if [ "$m" = SVG ]; then
2929
tmpfile2="$(mktemp /tmp/qimg-XXXXXXXX.png)"
30-
rsvg-convert -w "$w" -h "$h" -o "$tmpfile2" "$filename"
30+
if [ -n "$w" ] && [ "$w" -gt 0 ] && [ -n "$h" ] && [ "$h" -gt 0 ]; then
31+
rsvg-convert -w "$w" -h "$h" -o "$tmpfile2" "$filename"
32+
else
33+
rsvg-convert -o "$tmpfile2" "$filename"
34+
fi
3135
# downscale the image if necessary
3236
if [ -n "$forcemaxsize" ] && \
3337
{ [ "$w" -gt "$forcemaxsize" ] || [ "$h" -gt "$forcemaxsize" ]; }; then

0 commit comments

Comments
 (0)