Download presentation
Presentation is loading. Please wait.
Published byMeryem Yağmur Modified over 5 years ago
1
Python – May 25 Quiz Python’s imaging library Lab
Creating images Pretty parenthesizer problem Questions about homework?
2
PIL Python imaging library Practical note:
First, download if necessary Defines “Image” and many useful functions We’ll create images! Practical note: Need to add PIL to Python’s search path “import sys” and print sys.path to see what is ordinarily included Since sys.path is a list, you can simply append the PIL folder to it…. if necessary
3
3 steps image = Image.new(“RGB”, (100,100))
First, create image object image = Image.new(“RGB”, (100,100)) 2 parameters are mode and dimensions Next, paint your pixels usually in a nested loop of x & y values image.putpixel((x,y),(red,green,blue)) Finally, write image to file image.save(“myimage.jpg”) Does not have to be jpg. See handout
4
Reference These sections are especially helpful
These sections are especially helpful Concepts Image: Easy to use ImageDraw A “draw” object can create geometric shapes like circles, rectangles and polygons. Can also be used to read or modify existing image image.getpixel((x, y)) returns RGB tuple
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.