Reputation: 127
I have the following code:
same_dimensions: (Picture, Picture) -> Boolean
I need to create two pictures have both of them have equal height and width and it'll return True
, or False
if not. How do I start this?
Also, I need to do
copyright:() -> Picture
To return a new 20 pixel by 20 pixel Picture that has a white background, a black 16 by 16 oval and position (0,0)
, and a black letter C
(upper case) at position (6,3)
. I have no idea how to position these things.
[edited] I am working on the first function import media
def same_dimensions(pic1, pic2):
thats what i have down so far, my prof said that we can name the pictures ourselves.
Upvotes: 1
Views: 207
Reputation: 24921
Use the Image
module from PIL
:
>>> from PIL import Image
>>> im1 = Image.new('RGBA', (10,10))
>>> im2 = Image.new('RGBA', (10,10))
>>> im3 = Image.new('RGBA', (15,12))
>>> im1.size == im2.size
True
>>> im1.size == im3.size
False
Upvotes: 1
Reputation: 20654
The picture library usually used with Python is PIL (Python Image Library).
Upvotes: 1