Skip to content

Commit

Permalink
Primeira versão do wit.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxas committed Oct 11, 2013
1 parent 50b436b commit 04861e9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions wit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Image, ImageEnhance, os
from os.path import join

def batch():
infolder = os.getcwd()
watermark = str(raw_input('Type the watermark\'s file name (including the .png or .jpg): '))
if not watermark: watermark = "watermark.png"
outfolder = os.getcwd()+"/output/"
if not os.path.exists(outfolder): os.makedirs(outfolder)
mark_dir = infolder+"/"+watermark
mark = Image.open(mark_dir)
for root, dir, files in os.walk(infolder):
if watermark in files: files.remove(watermark)
for name in files:
try:
im = Image.open(join(root, name))
if im.mode != 'RGBA':
im = im.convert('RGBA')
layer = Image.new('RGBA', im.size, (0,0,0,0))
position = (im.size[0]-(mark.size[0]*2), im.size[1]-(mark.size[1]*2))
layer.paste(mark, position)
Image.composite(layer, im, layer).save( join(outfolder, name))
except Exception, (msg):
print ""

if __name__ == '__main__':
batch()

0 comments on commit 04861e9

Please sign in to comment.