2

The goal: SVG to PNG in python application

I'm converting SVG files to PNG's and having a strange problem. For most files, the PNG renders perfectly, but for some, the curves are rendered as straight lines between points.

Technology Used

  • Django
  • Wand ( an ImageMagick python binding )

Snippet from my view.py file

with Image( blob=temp_svg_data, format='svg' ) as original:
  original.format = 'png'
  original.save(filename=png_location)

Example of Bad SVG path.

<path fill="red" d="m27.518,42.335c3.9,0,7.043-3.166,7.043-7.055c0-3.911-3.144-7.055-7.043-7.055c-3.888,0-7.055,3.144-7.055,7.055
C20.463,39.169,23.63,42.335,27.518,42.335z"/>

Output

Notice how the red in the PNG rendered on the right isn't on a smooth curve.

http://cl.ly/image/2t3B2w0e393Y

Theories

  • Decimal Places. --Not it. Found curves that rendered well with 3 decimals.
  • SVG Generator. -- Not it. Found curves from AI versions that worked and didn't work.
  • Capitol vs Lowercase ( Absolute vs Relative ) letters in SVG move-to data.

0 Answers0