Create thumbnails of SVG renderings too

In some situations CairoSVG does not use the requested width/height.

See-also: https://github.com/Kozea/CairoSVG/issues/152
Fixes: commit 8dfc4111
parent 6c846c40
......@@ -33,18 +33,19 @@ def process_svg():
cairosvg.svg2png(url=logo, write_to=head,
parent_width=default_size[0],
parent_height=default_size[1])
process_image(head, head)
def process_image():
def process_image(input, output):
from PIL import Image
img = Image.open(logo)
img = Image.open(input)
img.thumbnail(default_size, Image.ANTIALIAS)
img.save(head, 'PNG')
img.save(output, 'PNG')
try:
if typedb.file(logo) in ('image/svg', 'image/svg+xml'):
process_svg()
else:
process_image()
process_image(logo, head)
except (ImportError, IOError):
remove(head)
if os.path.exists(logo):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment