Add text generation for video thumbnails.

This commit is contained in:
yrriban 2025-04-20 14:16:44 -04:00
parent 790f3af1a2
commit 72d89c0be9
3 changed files with 41 additions and 0 deletions

View file

@ -16,6 +16,9 @@ DEFAULT_IWAD=IWADS.joinpath("DOOM2.WAD")
THUMB_WIDTH=1280 THUMB_WIDTH=1280
THUMB_HEIGHT=720 THUMB_HEIGHT=720
FONT="League-Spartan-Bold"
TEXT_FILL_COLOR="white"
TEXT_STROKE_COLOR="srgb(176,0,0)"
MIRROR="https://youfailit.net/pub/idgames" # NYC MIRROR="https://youfailit.net/pub/idgames" # NYC
@ -68,6 +71,9 @@ def PwadPath(wad):
def BaseThumbPath(wad, mapstr): def BaseThumbPath(wad, mapstr):
return Ensure(OUTPUT.joinpath(wad)).joinpath("{}_map{}_base.png".format(wad, mapstr)) return Ensure(OUTPUT.joinpath(wad)).joinpath("{}_map{}_base.png".format(wad, mapstr))
def TextThumbPath(wad, mapstr):
return Ensure(OUTPUT.joinpath(wad)).joinpath("{}_map{}_text.png".format(wad, mapstr))
def VideoPath(wad, mapstr): def VideoPath(wad, mapstr):
return Ensure(OUTPUT.joinpath(wad)).joinpath("{}_map{}.mp4".format(wad, mapstr)) return Ensure(OUTPUT.joinpath(wad)).joinpath("{}_map{}.mp4".format(wad, mapstr))

34
dcc/text.py Normal file
View file

@ -0,0 +1,34 @@
import dcc.doom_base
import sys
import wand.drawing
import wand.image
class Text(dcc.doom_base.WadMap):
def get_parser(self, prog_name):
parser = super().get_parser(prog_name)
parser.add_argument("--nomap", action="store_true")
parser.add_argument("--demotype", default="UV-Max")
return parser
def take_action(self, parsed_args):
text = sys.stdin.read().rstrip()
if not parsed_args.nomap:
text = "MAP{}: {}".format(parsed_args.map, text)
text = "{}\n{} Demo".format(text, parsed_args.demotype)
with wand.image.Image(height=dcc.config.THUMB_HEIGHT,width=dcc.config.THUMB_WIDTH) as img:
with wand.drawing.Drawing() as draw:
draw.font = dcc.config.FONT
draw.font_size=64
draw.fill_color=wand.color.Color(dcc.config.TEXT_FILL_COLOR)
draw.stroke_color=wand.color.Color(dcc.config.TEXT_STROKE_COLOR)
draw.stroke_width=10
draw.text_interline_spacing=-16
draw.text(5,int(draw.font_size),text)
draw(img)
draw.stroke_color=wand.color.Color("none")
draw.stroke_width=0
draw.text(5,int(draw.font_size),text)
draw(img)
img.trim()
img.reset_coords()
img.save(filename=dcc.config.TextThumbPath(parsed_args.wad, parsed_args.map))

View file

@ -30,6 +30,7 @@ setup(
'check = dcc.check:Check', 'check = dcc.check:Check',
'extract = dcc.extract:Extract', 'extract = dcc.extract:Extract',
'fetch = dcc.fetch:Fetch', 'fetch = dcc.fetch:Fetch',
'text = dcc.text:Text',
], ],
}, },
zip_safe=False, zip_safe=False,