Tauquir
Tauquir

Reputation: 6903

how to displace an image in python?

I have an image size 400*200. I have a frame size 400* 300.

I want to put the image in the center of frame. That is my image cordinate (0,0) starts with the frame cordinates (0,50).

Upvotes: 1

Views: 694

Answers (1)

bobince
bobince

Reputation: 536329

frame= Image.new(image.mode, (400, 300))
frame.paste(image, (0, 50))

(frame.paste(image, (0, 50), image) if the image to be framed has a transparency mask you want to keep. And pass a third parameter to Image.new to set the background colour of the frame if the default isn't what you want.)

Upvotes: 2

Related Questions