doomcc/dcc/thumb.py

37 lines
1.1 KiB
Python
Raw Normal View History

2025-04-20 18:59:58 -04:00
import dcc.config
import dcc.doom_base
import wand.color
import wand.image
2025-06-15 13:33:33 -04:00
2025-04-20 18:59:58 -04:00
class Thumb(dcc.doom_base.WadMap):
2025-06-15 13:33:33 -04:00
def get_parser(self, prog_name):
parser = super().get_parser(prog_name)
parser.add_argument("--index", action="store_true")
return parser
def take_action(self, parsed_args):
base = self.base_thumb_path()
text = self.text_thumb_path()
mdoom = self.m_doom_path()
with (
wand.image.Image(filename=base) as bi,
wand.color.Color("transparent") as tc
):
with wand.image.Image(filename=text) as ti:
ti.border(tc, 5, 5)
bi.composite(ti, gravity="south_west")
2025-04-20 18:59:58 -04:00
2025-06-15 13:33:33 -04:00
with wand.image.Image(filename=mdoom) as mdi:
mdi.border(tc, 5, 5)
bi.composite(mdi, gravity="north_west")
2025-04-20 18:59:58 -04:00
2025-06-15 13:33:33 -04:00
if parsed_args.index:
with wand.image.Image(
filename=self.fabricate.joinpath("doomed_index.png")
2025-06-15 13:33:33 -04:00
) as di:
di.border(tc, 1, 1)
bi.composite(di, gravity="north_east")
2025-04-20 18:59:58 -04:00
2025-06-15 13:33:33 -04:00
bi.save(filename=self.thumb_path())