Skip to content

Commit

Permalink
Added more for converting svg to png
Browse files Browse the repository at this point in the history
  • Loading branch information
dcunhas committed Jun 15, 2016
1 parent c4b608d commit 5464e3f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions convert_images.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from wand.image import Image
from wand.image import Image as WandImage
import StringIO
from webclient.models import Image, ImageLabel

def convertSVGtoPNG(filepath):
def convertSVGtoPNG(file):
#Convert copy of image to new format
with Image(file).clone() as img:
with WandImage(file).clone() as img:
img.format = 'png'
img.save(filename='C:/Users/Sandeep/test.png')

Expand All @@ -12,8 +13,13 @@ def stringToSVGString(str):
height = 386
width = 241


return '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' \
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' \
'<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" ' \
'xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve" height=%i ' \
' width=%i>%s</svg>' %(height, width, str)
' width=%i>%s</svg>' %(height, width, str)

def convertSVGs(LabelList):
for label in LabelList:
convertSVGtoPNG(stringToSVGString(label.labelShapes))

0 comments on commit 5464e3f

Please sign in to comment.