add option to render using imagemagick

This commit is contained in:
derchris 2019-01-20 06:41:57 +01:00
parent 43f08547f0
commit f3b8deb63b
4 changed files with 24 additions and 10 deletions

View file

@ -47,10 +47,10 @@ $ pip3 install -r requirements.txt
##### Debian
On debian, for python lxml dependencies:
On debian you need to install ImageMagick and Python lxml dependencies:
```
sudo apt-get install libxml2-dev libxslt1-dev
sudo apt-get install libmagickwand-dev libmagickcore5-extra libxml2-dev libxslt1-dev
```
Quick start

View file

@ -48,6 +48,10 @@ parser.add_argument('--skip-frames', action="store", default=None, type=int, hel
Skip first n frames e.g. to quickly rerender during debugging.
Usage: ./make.py yourproject/ --debug --skip-frames 300
''')
parser.add_argument('--imagemagick', action="store_true", default=False, help='''
Render frames using ImageMagick instead of Inkscape.
Usage: ./make.py yourproject/ --imagemagick
''')
if len(sys.argv) < 2:
parser.print_help()

View file

@ -13,6 +13,7 @@ import cssutils
import logging
import subprocess
from urllib.request import urlopen
from wand.image import Image
# Frames per second. Increasing this renders more frames, the avconf-statements would still need modifications
fps = 25
@ -168,6 +169,14 @@ def rendertask(task):
width = 1024
height = 576
if args.imagemagick:
# invoke imagemagick to convert the generated svg-file into a png inside the .frames-directory
infile = '{0}/.gen.svg'.format(task.workdir)
outfile = '{0}/.frames/{1:04d}.png'.format(task.workdir, frameNr)
with Image(filename=infile) as img:
with img.convert('png') as converted:
converted.save(filename=outfile)
else:
# invoke inkscape to convert the generated svg-file into a png inside the .frames-directory
cmd = 'cd {0} && inkscape --export-background=white --export-background-opacity=0 --export-width={2} --export-height={3} --export-png=$(pwd)/.frames/{1:04d}.png $(pwd)/.gen.svg 2>&1 >/dev/null'.format(task.workdir, frameNr, width, height)
errorReturn = subprocess.check_output(cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT)

View file

@ -1,3 +1,4 @@
cssutils==1.0.1
lxml==3.4.4
svg.path==2.2
lxml==4.2.5
svg.path==3.0
Wand==0.5.0