Page 1 of 1

convert fills disk on simple svg to png conversion

Posted: 2017-01-28T13:56:08-07:00
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!

Re: convert fills disk on simple svg to png conversion

Posted: 2017-01-28T15:07:33-07:00
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

Re: convert fills disk on simple svg to png conversion

Posted: 2017-01-28T15:27:20-07:00
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.

Re: convert fills disk on simple svg to png conversion

Posted: 2017-01-29T09:12:26-07:00
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.

Re: convert fills disk on simple svg to png conversion

Posted: 2017-01-29T23:56:11-07:00
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.