0

I am using python2/PIL to resize/overlay images. The images should be the same size without scaling but with and without scaling the result is the same: the background image has the right size and the foreground image is only a fourth of it. The saved image has the right size, the background too but the foreground I sonly a fourth of the whole image on the upper left. Why?

foregroundimage = Image.open(self.foregrund.new_foreground())
backgroundimage = Image.open(filename)
foregroundimage.thumbnail((highres_w,highres_h),Image.ANTIALIAS)
backgroundimage.thumbnail((highres_w,highres_h),Image.ANTIALIAS)
backgroundimage.paste(foregroundimage,(0,0),foregroundimage)
backgroundimage.save(outfilename)
555
  • 147
  • 8
  • I don't 100% understand your question, but maybe the problem is that `thumbnail` is free to make the image _smaller_ than the size you specify. If you want the image to be exactly the size specified, use `resize` instead. Related reading: [What is the difference between Image.resize and Image.thumbnail in Pillow-Python](http://stackoverflow.com/q/29367990/953482) – Kevin Feb 08 '17 at 19:44
  • Without the thumbnail-command the saved picture is exactly the same! Even both Images have the same size before! Somehow the paste-function seems to change the size of the foregroundimage. I don't want that. I want them to overlay in the same size! – user2098738 Feb 08 '17 at 20:58
  • OK, I am adding an image to describe the problem further: http://pasteall.org/pic/show.php?id=112273 The black frame is the foreground, the white picture is the background. The pictures are 100% the same size in original. This is the result. But I want the frame to go over the whole picture! – user2098738 Feb 09 '17 at 05:34

0 Answers0