dist: Use Pillow to generate application icons.

This commit is contained in:
Mike Swanson 2017-07-31 16:41:07 -07:00
parent dbe2a19bd6
commit 0d6bb9fc72
3 changed files with 40 additions and 8 deletions

11
dist/Makefile vendored
View file

@ -3,18 +3,13 @@ man-%: freedoom.adoc
a2x -f manpage $*.adoc
icon-freedm:
convert -resize 64x64 ../graphics/titlepic/freedm_title2.png \
freedm.png
./pillow-resize ../graphics/titlepic/freedm_title2.png freedm.png 64 64
icon-freedoom1:
convert -trim +repage -extent 48x48 -gravity center \
-transparent \#00ffff -background \#00ffff \
../sprites/playa2a8.png freedoom1.png
./pillow-compose ../sprites/playa2a8.png freedoom1.png 64 64
icon-freedoom2:
convert -trim +repage -extent 64x64 -gravity center \
-transparent \#00ffff -background \#00ffff \
../sprites/heada1.png freedoom2.png
./pillow-compose ../sprites/heada1.png freedoom2.png 64 64
clean:
rm -f *.6 *.png freedm.adoc freedoom1.adoc freedoom2.adoc

26
dist/pillow-compose vendored Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env python
# Simple and dumb Pillow-based compositor
# Usage: pillow-compose src-img.png dst-img.png WIDTH HEIGHT
import sys
from PIL import Image
src = Image.open(sys.argv[1])
img = Image.new('RGBA', (int(sys.argv[3]), int(sys.argv[4])), (0, 0, 0, 0))
# Pillow's compositing won't accept negative values. This can happen
# if the destination image is smaller on at least on axis than the
# source image.
if img.size[0] - src.size[0] < 0:
off_x = 0
else:
off_x = (img.size[0] - src.size[0]) // 2
if img.size[1] - src.size[1] < 0:
off_y = 0
else:
off_y = (img.size[1] - src.size[1]) // 2
img.alpha_composite(src.convert('RGBA'), (off_x, off_y))
img.save(sys.argv[2])

11
dist/pillow-resize vendored Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env python
# Simple and dumb Pillow-based resizer
# Usage: pillow-resize src-img.png dst-img.png WIDTH HEIGHT
import sys
from PIL import Image
img = Image.open(sys.argv[1])
img.thumbnail((int(sys.argv[3]), int(sys.argv[4])))
img.save(sys.argv[2])