convert fills disk on simple svg to png conversion

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
cdaringe
Posts: 2
Joined: 2017-01-28T13:52:56-07:00
Authentication code: 1151

convert fills disk on simple svg to png conversion

Post by cdaringe »

hello:

the subject is a primer, but an example and context can be found in this tiny repo: https://github.com/cdaringe/image-magick-svg-kaboom

thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert fills disk on simple svg to png conversion

Post by fmw42 »

I am not an SVG expert, but try each of these to call different SVG renderers separately and see if any work. When you have multiple renderers, I do not know which it defaults to. Have you tried Inkscape?

Code: Select all

convert -background none MSVG:logo-clean.svg -resize 64x64 ico64.png

Code: Select all

convert -background none RSVG:logo-clean.svg -resize 64x64 ico64.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert fills disk on simple svg to png conversion

Post by snibgo »

Your SVG contains
width="225756.934" height="158520.242"
This is 35 giga pixels, for which Q16 would need 286 GB of memory.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert fills disk on simple svg to png conversion

Post by magick »

See https://www.imagemagick.org/script/security-policy.php. You can specify a maximum width or height and ImageMagick will report an exception if either limit is exceeded. However, the problem may not even be with ImageMagick-- but instead inkscape. ImageMagick has multiple SVG renderers. The default is inkscape. If that is the renderer you are using, the bug report may need to be pushed to their developers. To verify, type

Code: Select all

convert -verbose logo.svg null:
If it reports inkscape, its inkscape that is likely filling your disk space. It might complete and return to ImageMagick where the security policy will deny further progress.

If we force an alternative renderer, MSVG, we get expected results with a proper security policy:

Code: Select all

-> convert msvg:logo.svg null:
convert: width or height exceeds limit' @ error/cache.c/OpenPixelCache/3440.
convert: no images defined `null:' @ error/convert.c/ConvertImageCommand/3254.
If we use the final SVG renderer, the RSVG delegate library, it also fails gracefully:

Code: Select all

> convert logo.svg null:
convert: memory allocation failed `logo.svg' @ error/svg.c/ReadSVGImage/3076.
convert: no images defined `null:' @ error/convert.c/ConvertImageCommand/3254.
cdaringe
Posts: 2
Joined: 2017-01-28T13:52:56-07:00
Authentication code: 1151

Re: convert fills disk on simple svg to png conversion

Post by cdaringe »

cool. thanks for the tips, all!

Code: Select all

$ convert -verbose logo-clean.svg null:
'inkscape' '/var/folders/fr/wzg7ht8x7_x7dcjz036g1wlc0000gp/T/magick-99768D_F4TaJK4LvT' --export-png='/var/folders/fr/wzg7ht8x7_x7dcjz036g1wlc0000gp/T/magick-997681i-om65MXNWG' --export-dpi='90,90' --export-background='rgb(100%,100%,100%)' --export-background-opacity='1' > '/var/folders/fr/wzg7ht8x7_x7dcjz036g1wlc0000gp/T/magick-99768YwZZ8ALs5J3h' 2>&1
sure enough, inkscape. even this command completely locked up. `pkill -9 -f convert` wouldn't take it down.
Post Reply