30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import dcc.config
|
|
import dcc.doom_base
|
|
import wand.color
|
|
import wand.image
|
|
|
|
class Thumb(dcc.doom_base.WadMap):
|
|
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 = dcc.config.BaseThumbPath(parsed_args.wad, parsed_args.map, parsed_args.name)
|
|
text = dcc.config.TextThumbPath(parsed_args.wad, parsed_args.map, parsed_args.name)
|
|
mdoom = dcc.config.MDoomPath(parsed_args.wad)
|
|
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")
|
|
|
|
with wand.image.Image(filename=mdoom) as mdi:
|
|
mdi.border(tc, 5, 5)
|
|
bi.composite(mdi, gravity="north_west")
|
|
|
|
if parsed_args.index:
|
|
with wand.image.Image(filename=dcc.config.OUTPUT.joinpath("doomed_index.png")) as di:
|
|
di.border(tc, 1, 1)
|
|
bi.composite(di, gravity="north_east")
|
|
|
|
bi.save(filename=dcc.config.ThumbPath(parsed_args.wad, parsed_args.map, parsed_args.name))
|