add option to render using imagemagick
This commit is contained in:
parent
43f08547f0
commit
f3b8deb63b
4 changed files with 24 additions and 10 deletions
|
@ -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
|
||||
|
|
4
make.py
4
make.py
|
@ -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()
|
||||
|
|
21
renderlib.py
21
renderlib.py
|
@ -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,12 +169,20 @@ def rendertask(task):
|
|||
width = 1024
|
||||
height = 576
|
||||
|
||||
# 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)
|
||||
if errorReturn != '':
|
||||
print("inkscape exitted with error\n" + errorReturn)
|
||||
# sys.exit(42)
|
||||
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)
|
||||
if errorReturn != '':
|
||||
print("inkscape exitted with error\n" + errorReturn)
|
||||
# sys.exit(42)
|
||||
|
||||
# increment frame-number
|
||||
frameNr += 1
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue