File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,22 +21,29 @@ elif ! [ -r "${filename}" ]; then
2121 exit 1
2222fi
2323
24- s=" $( gm identify -format ' %w %h %m' " $filename " ) "
25- w=" $( echo " $s " | cut -d " " -f 1) "
26- h=" $( echo " $s " | cut -d " " -f 2) "
27- m=" $( echo " $s " | cut -d " " -f 3) "
24+ read -r w h m << EOF
25+ $( gm identify -format ' %w %h %m' " $filename " )
26+ EOF
2827if [ " $m " = SVG ]; then
2928 tmpfile2=" $( mktemp /tmp/qimg-XXXXXXXX.png) "
30- rsvg-convert -w " $w " -h " $h " -o " $tmpfile2 " " $filename "
29+ if [ -n " $w " ] && [ " $w " -gt 0 ] && [ -n " $h " ] && [ " $h " -gt 0 ]; then
30+ rsvg-convert -w " $w " -h " $h " -o " $tmpfile2 " " $filename "
31+ else
32+ rsvg-convert -o " $tmpfile2 " " $filename "
33+ # re-read dimensions from the rendered PNG since SVG had no explicit size
34+ read -r w h << EOF
35+ $( gm identify -format ' %w %h' " $tmpfile2 " )
36+ EOF
37+ fi
3138 # downscale the image if necessary
3239 if [ -n " $forcemaxsize " ] && \
3340 { [ " $w " -gt " $forcemaxsize " ] || [ " $h " -gt " $forcemaxsize " ]; }; then
3441 gm convert " $tmpfile2 " -scale " ${forcemaxsize} x${forcemaxsize} " " $tmpfile2 "
3542 fi
3643 # read the size again, because icon may not be a square or could have changed with convert
37- s= " $( gm identify -format ' %w %h ' " $tmpfile2 " ) "
38- w= " $( echo " $s " | cut -d " " -f 1 ) "
39- h= " $( echo " $s " | cut -d " " -f 2 ) "
44+ read -r w h << EOF
45+ $( gm identify -format ' %w %h ' " $tmpfile2 " )
46+ EOF
4047 filename=" $tmpfile2 "
4148fi
4249echo " $w $h "
You can’t perform that action at this time.
0 commit comments