Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python – May 25 Quiz Python’s imaging library Lab

Similar presentations


Presentation on theme: "Python – May 25 Quiz Python’s imaging library Lab"— Presentation transcript:

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


Download ppt "Python – May 25 Quiz Python’s imaging library Lab"

Similar presentations


Ads by Google