

Pillow
Presentation
•
•
Practice Problem
•
Hard
Аңсар Әкім
Used 2+ times
FREE Resource
13 Slides • 5 Questions
1
Creating images in Python
Visual programming is essential in today's digital landscape, enabling effective communication and creativity.
It plays a pivotal role in web development, data science, and user experience design.
2
Determine Colors by RGB Code
Understand RGB color representation.
Understand how to specify colors using RGB codes.
Use PIL for Image Manipulation
Learn Image module commands in Pillow (PIL).
Explore loading, creating, resizing, and saving images.
Apply Graphic Primitives
Discover how to use graphic primitives for drawing.
Create visual elements, such as lines, circles, and rectangles, in Python.
Learning Objectives
3
Web Development: Creating visually appealing websites and user interfaces.
Data Science: Visualizing data and results for better understanding.
Game Design: Developing graphics, animations, and interactive elements.
Digital Art: Crafting digital illustrations, designs, and multimedia.
Visual programming is a versatile skill used in a wide range of fields, including:
4
RGB (Red, Green, Blue) is a fundamental color model used in digital imaging.
RGB codes represent colors by specifying intensity levels of each component (0 to 255):
(0, 0, 0) represents black.
(255, 255, 255) represents white.
Equal component values yield various shades of gray.
(255, 100, 100, 128) - ???
RGB Color Scheme
RGB in Python
In Python, RGB colors are represented as tuples, like (255, 0, 0) for red.
Python provides a straightforward way to work with RGB color codes.
5
6
Pillow (PIL) is a Python Imaging Library that simplifies image processing.
It offers a powerful set of tools for image manipulation and creation.
Introduction to PIL Library
Mini-research 1. Image Manipulation with PIL
Explore commands in the Image module of Pillow:
Installation
Load: Open and load images.
Create: Create new blank images.
Resize: Adjust image dimensions.
Save: Save modified images to files.
7
Multiple Choice
Which code snippet correctly opens an image file named "example.jpg" using the Pillow library?
from PIL import Image img = Image.open("example.jpg")
import Image img = Image.open("example.jpg")
from Pillow import Image img = Image.open("example.jpg")
import PIL img = PIL.open("example.jpg")
8
Multiple Choice
Which code snippet correctly resizes an image named "input.jpg" to 300x300 pixels using Pillow?
from PIL import Image img = Image.open("input.jpg") img = img.resize((300, 300))
from PIL import Image img = Image.open("input.jpg") img.resize((300, 300)).show()
from PIL import Image img = Image.open("input.jpg") img.thumbnail((300, 300))
from PIL import Image img = Image.open("input.jpg") img.resize(300, 300).show()
9
Multiple Choice
Which code correctly saves the image in "output.png" format using the Pillow library?
from PIL import Image img = Image.open("input.jpg") img.save("output.png")
from PIL import Image img = Image.open("input.jpg") img.save("output.jpg")
from PIL import Image img = Image.open("input.jpg") img.save("output.png", format="JPEG")
from PIL import Image img = Image.open("input.jpg") img.save("output.png", format="PNG")
10
Introduce graphic primitives, essential for creating drawings:
Lines: For straight-line segments.
Circles: To draw circles and ellipses.
Rectangles: To create rectangular shapes.
Complex Graphic Composition
Mini-research 2. Graphic Primitives
Drawing with PIL
Provide code examples for drawing shapes and lines using PIL:
Demonstrate how to create visuals within Python scripts.
Showcase examples of drawings.
12
Multiple Choice
Which code snippet creates a new image with a blue background and size 400x300 pixels using Pillow?
from PIL import Image img = Image.new("RGB", (400, 300), (0, 0, 255))
from PIL import Image img = Image.new("RGBA", (400, 300), (0, 0, 255, 255))
from PIL import Image img = Image.new("RGB", (400, 300), (255, 0, 0))
from PIL import Image img = Image.new("RGB", (300, 400), (0, 0, 255))
13
Task 1
Check if Pillow library is
installed on your
computer.
If yes, uninstall using
pip uninstall pillow
command in command
line
Install using pip install
pillow command in
command line
14
Task 2
• Choose any image.
• Determine the size of image using
Pillow
• Determine the color of the left-top
pixel using Pillow
• Check the output with Photoshop (if
you have)
15
Task 3
Create this rectangle using Pillow
with given parameters. Size 200 x
200, color blue (try other colors
using RGB). And save it on
desktop.
16
Task 4
Draw a line using Pillow
17
Capabilities of Pillow library
https://www.youtube.com/watch?v=5QR-
dG68eNE&ab_channel=ClearCode
Watch a video to see other capabilities of library in
practice.
18
Task 5
Create a beautiful image using
the Pillow and your creativity.
Creating images in Python
Visual programming is essential in today's digital landscape, enabling effective communication and creativity.
It plays a pivotal role in web development, data science, and user experience design.
Show answer
Auto Play
Slide 1 / 18
SLIDE
Similar Resources on Wayground
12 questions
Natural Selection
Presentation
•
7th - 9th Grade
14 questions
Slope and Slope Intercept Form
Presentation
•
9th - 12th Grade
11 questions
Analyzing Graphs
Presentation
•
8th Grade
15 questions
Light Energy
Presentation
•
5th Grade
13 questions
Vocabulary Builders
Presentation
•
6th - 8th Grade
13 questions
Nonfiction Text Features
Presentation
•
6th - 8th Grade
12 questions
Mummification
Presentation
•
6th Grade
14 questions
Dilations
Presentation
•
7th - 8th Grade
Popular Resources on Wayground
10 questions
How much do you know about our Portrait of an Eagle?
Quiz
•
10th Grade
10 questions
Fast Food Slogans
Quiz
•
6th - 8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
Discover more resources for
10 questions
How much do you know about our Portrait of an Eagle?
Quiz
•
10th Grade
10 questions
Fast Food Slogans
Quiz
•
6th - 8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade