2
1个PNG我有2个图像:PIL - 使从JPG和PNG帧
- PNG(99x97)用白色的,旋转框架和其余部分是完全透明。
- JPG - 是我生成的缩略图(80×80)
现在我希望把缩略图到我的框架,所以它看起来像某种绘画。我该怎么办?
编辑:
我忘了补充,即图片必须是下架。
我有一些剧本,但它仅显示一个框架。在它里面没有任何图片:/
import Image, ImageDraw
img_size = (99,97)
im = Image.open('logo.jpg')
picture = im.crop((0,0,80,80))
frame = Image.open('thumb-frame.png')
picture = picture.convert('RGBA')
background = Image.new('RGBA', img_size, (255, 255, 255, 0))
background.paste(picture, (10,9))
background.paste(frame, (0,0))
background.save('logocopy.png', 'PNG')
编辑:
问题解决了。我不得不添加alpha遮罩到.paste()
import Image
im = Image.open('logo.jpg')
picture = im.crop((0,0,80,80))
picture = picture.convert('RGBA')
frame = Image.open('thumb-frame.png')
background = Image.new('RGBA', frame.size, (255, 255, 255, 0))
background.paste(picture, (10,9))
background.paste(frame, (0,0), frame)
background.save('logocopy.png', 'PNG')
你试过了什么?我们不会为您编写代码,但我们可以帮助您解决代码中的问题:) – 2011-12-29 12:49:04
@CédricJulien查看我编辑的帖子。 – tunarob 2011-12-29 13:04:23
首先绘制一张图片,然后在该图片上方绘制一帧。如果框架透明度设置正确,你应该得到你想要的。 – demalexx 2011-12-29 13:08:21