WorksheetsPython Image Library
Total questions: 10
Worksheet time: 5mins
What does the Image.new() function in PIL do?
Create a new Python image file.
Create a new empty image with a specified mode and size.
Load an existing image file
Crop an image to a specified size
Which Python library is commonly used for image manipulation and drawing operations?
PIL (Python Image Library)
NumPy
OpenCV
Matplotlib
What does the ImageDraw module in PIL allow you to do?
Resize an image
Create a new image
Draw shapes and text on an image
Convert images to different formats
Which function is used to draw an ellipse on an image using PIL?
ImageDraw.draw_circle()
ImageDraw.draw_ellipse()
Image.draw_ellipse()
Image.ellipse()
What does the ImageDraw.rectangle() method in PIL do?
Crop the image to a specified rectangle
Draw a filled rectangle on an image
Rotate the image by a specified angle
Resize the image to a rectangle shape
Which function is used to draw a polygon on an image using PIL?
ImageDraw.draw_polygon()
ImageDraw.draw_shape()
Image.draw_polygon()
Image.polygon()
What parameter is required when creating a new image using Image.new()?
Image mode (e.g., 'RGB', 'RGBA')
Image filename
Image size in pixels
Image DPI (Dots Per Inch)
How do you specify the color of the shapes you draw with PIL's ImageDraw module?
By setting the color attribute of the image
By specifying the color when creating the image
By using the fill parameter in drawing methods
By calling the setColor() method on the image
What is the purpose of the outline parameter in the ImageDraw.rectangle() method in PIL?
It sets the background color of the rectangle.
It specifies the width of the rectangle's border.
It sets the color of the rectangle's border.
It determines the shape of the rectangle.
How can you draw a filled polygon with a transparent background using PIL?
Set the polygon's color to be transparent using the ImageDraw.set_alpha() method.
Use the 'RGBA' mode when creating the image and specify the polygon's color with an alpha value less than 255.
There is no way to create a filled polygon with a transparent background in PIL.
Set the background parameter of the ImageDraw.polygon() method to 'transparent'.
