glt24: make inkscape rendering usable again

This commit is contained in:
Sophie Schiller 2024-04-04 10:31:05 +02:00
parent 1f8d859bbc
commit 58bc29249e
4 changed files with 23 additions and 18 deletions

View file

@ -21,8 +21,8 @@ def introFrames(args):
frames = 2*fps frames = 2*fps
for i in range(0, frames): for i in range(0, frames):
yield( yield(
('title', 'style', 'opacity', easeInQuad(i, 0, 1, frames)), ('title', 'style', 'opacity', easeInQuad(i, 0.01, 1, frames)),
('persons', 'style', 'opacity', easeInQuad(i, 0, 1, frames)), ('persons', 'style', 'opacity', easeInQuad(i, 0.01, 1, frames)),
) )
#show whole image for 5 seconds #show whole image for 5 seconds
@ -59,15 +59,15 @@ def debug():
'../intro.ts', '../intro.ts',
introFrames, introFrames,
{ {
'$title': "Long Long Long title is LONG", '$title': " Fully declarative Homelab on NixOS ❄️",
'$speaker': 'Long Name of Dr. Dr. Prof. Dr. Long Long' '$persons': 'Long Name of Dr. Dr. Prof. Dr. Long Long'
} }
) )
render('outro.svg', #render('outro.svg',
'../outro.ts', # '../outro.ts',
outroFrames # outroFrames
) #)
def tasks(queue, args, idlist, skiplist): def tasks(queue, args, idlist, skiplist):

View file

@ -431,10 +431,10 @@
id="tspan5627" id="tspan5627"
x="941.19" x="941.19"
y="594.2323" y="594.2323"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:1.25;font-family:'Titillium Web';-inkscape-font-specification:'Titillium Web, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle">$title</tspan></text> style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:1.25;font-family:'Titillium Web';-inkscape-font-specification:'Titillium Web, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;opacity:0.5">$title</tspan></text>
<text <text
xml:space="preserve" xml:space="preserve"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;opacity:0.5"
x="939.93469" x="939.93469"
y="680.10602" y="680.10602"
id="persons"><tspan id="persons"><tspan
@ -442,7 +442,7 @@
id="tspan5631" id="tspan5631"
x="939.93469" x="939.93469"
y="680.10602" y="680.10602"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:1.25;font-family:'Titillium Web';-inkscape-font-specification:'Titillium Web, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1">$persons</tspan></text> style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40px;line-height:1.25;font-family:'Titillium Web';-inkscape-font-specification:'Titillium Web, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;opacity:1">$persons</tspan></text>
<text <text
xml:space="preserve" xml:space="preserve"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View file

@ -99,7 +99,9 @@ renderlib.args = args
# sys.exit(1) # sys.exit(1)
def render(infile, outfile, sequence, parameters={}, workdir=os.path.join(projectname, 'artwork')): cwd = os.getcwd()
def render(infile, outfile, sequence, parameters={}, workdir=os.path.join(cwd, projectname, 'artwork')):
task = renderlib.Rendertask(infile=infile, outfile=outfile, task = renderlib.Rendertask(infile=infile, outfile=outfile,
sequence=sequence, parameters=parameters, workdir=workdir) sequence=sequence, parameters=parameters, workdir=workdir)
return renderlib.rendertask(task) return renderlib.rendertask(task)

View file

@ -97,7 +97,7 @@ def renderFrame(infile, task, outfile):
converted.save(filename=outfile) converted.save(filename=outfile)
elif args.resvg: elif args.resvg:
# invoke inkscape to convert the generated svg-file into a png inside the .frames-directory # invoke inkscape to convert the generated svg-file into a png inside the .frames-directory
cmd = 'resvg --background white --width={1} --height={2} "{4}" "{3}" 2>&1 >/dev/null'.format( cmd = 'resvg --use-fonts-dir ~/.local/share/fonts/ --background white --width={1} --height={2} "{4}" "{3}" 2>&1 >/dev/null'.format(
task.workdir, width, height, outfile, infile) task.workdir, width, height, outfile, infile)
errorReturn = subprocess.check_output( errorReturn = subprocess.check_output(
cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT, cwd=task.workdir) cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT, cwd=task.workdir)
@ -107,12 +107,15 @@ def renderFrame(infile, task, outfile):
else: else:
# invoke inkscape to convert the generated svg-file into a png inside the .frames-directory # invoke inkscape to convert the generated svg-file into a png inside the .frames-directory
cmd = 'inkscape --export-background=white --export-background-opacity=0 --export-width={1} --export-height={2} --export-filename="{3}" "{4}" --pipe 2>&1 >/dev/null'.format( cmd = 'inkscape --export-background=white --export-background-opacity=0 --export-width={1} --export-height={2} --export-filename="{3}" "{4}"'.format(
task.workdir, width, height, os.path.abspath(outfile), os.path.abspath(infile)) task.workdir, width, height, os.path.abspath(outfile), os.path.abspath(infile))
try:
errorReturn = subprocess.check_output( errorReturn = subprocess.check_output(
cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT, cwd=task.workdir) cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT, cwd=task.workdir)
if errorReturn != '': except subprocess.CalledProcessError as e:
print("inkscape exited with error\n" + errorReturn) print(f"inkscape exited with error")
print(f"returncode={e.returncode}")
print(f"output={e.output}")
# sys.exit(42) # sys.exit(42)