Python,PIL + Images2GIF强制转换为Unicode

时间:2018-03-28 09:12:26

标签: python python-2.7 python-imaging-library animated-gif

我正在尝试使用python为动画图像添加水印,但是我收到了一条错误消息: coercing to Unicode: need string or buffer, Image found

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))
            writeGif('out.gif', frames_out, duration=0.5, dither=0)
    except Exception, (msg):
        print msg

def test():
    water(sys.argv[1], "water.png")

文件:
This is image that i want to put my watermark - neo.gif
My watermark - water.png
error during executing

如何修复该错误?我无法在gif图像上添加水印 以下是my previous post

上的完整代码

0 个答案:

没有答案