from PIL import Image
import images2gif as i2g
import sys, os
def water(img, watermark):
mark = Image.open(watermark)
try:
im = Image.open(img)
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], im.size[1]-mark.size[1])
layer.paste(mark, position)
frames = i2g.readGif(im, False)
frames_out = []
for frame in frames:
frames_out.append(Image.composite(layer, frame, layer)
i2g.writeGif('out.gif',frames_out, duration=0.5, dither=0)
except Exception, (msg):
print msg
def test():
water(sys.argv[1], "water.png")
if __name__ == '__main__':
test()
我正在尝试在上面的gif图像上制作水印。
这是完整的代码,但它会出错:
i2g.writeGif('out.gif',frames_out, duration=0.5, dither=0)
^
SyntaxError: invalid syntax
我做错了什么?