37 lines
858 B
Python
Executable File
37 lines
858 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
# v0.1 jaroslav@hackerspace.pl
|
|
|
|
import sys
|
|
import Image
|
|
|
|
### settings
|
|
src_img_path="./"
|
|
dst_img_path="../public_html/"
|
|
dst_img_name="result.jpg"
|
|
### end of settings
|
|
|
|
if (len(sys.argv) != 3):
|
|
print "usage: %s current target" % (sys.argv[0])
|
|
sys.exit(1)
|
|
|
|
current=float(sys.argv[1])
|
|
target=float(sys.argv[2])
|
|
|
|
img_width=108
|
|
img_height=97
|
|
|
|
h=int((current/target)*img_height)
|
|
mana_full_img=Image.open(src_img_path+"mana_ball_demon_full.png")
|
|
mana_empty_img=Image.open(src_img_path+"mana_ball_demon_empty.png")
|
|
|
|
# calculate the size of region we want to copy from full mana img
|
|
box=(0,img_height-h,img_width,img_height)
|
|
region=mana_full_img.crop(box)
|
|
|
|
mana_result_img=Image.new('RGBA',(img_width,img_height))
|
|
mana_result_img.paste(mana_empty_img)
|
|
mana_result_img.paste(region,box)
|
|
mana_result_img.save(dst_img_path+dst_img_name,"JPEG")
|
|
|