Knowee
Questions
Features
Study Tools

Using what you have learned about the tools available from Pillow, write a program (yes, a program, so if you write a function, make sure to call it) that creates the following 9 by 7 black and white image, and saves it to a file named 'smile.png'.

Question

Using what you have learned about the tools available from Pillow, write a program (yes, a program, so if you write a function, make sure to call it) that creates the following 9 by 7 black and white image, and saves it to a file named 'smile.png'.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a Python program using the Pillow library to create a 9x7 black and white image that looks like a smiley face:

from PIL import Image, ImageDraw

# Create a new image with white background
img = Image.new('1', (9, 7), 1)
draw = ImageDraw.Draw(img)

# Draw the eyes
draw.point((2, 2), fill=0)
draw.point((6, 2), fill=0)

# Draw the smile
for i in range(2, 7):
    draw.point((i, 5), fill=0)

# Save the image
img.save('smile.png')

This program first creates a new 9x7 image with a white background. Then it uses the ImageDraw.Draw function to create a drawable image. It then draws two points for the eyes and a line for the mouth. Finally, it saves the image to a file named 'smile.png'.

This problem has been solved

Similar Questions

ay you want to input a picture of a person’s face (A), and output whether or not they are smiling (B). Because this is a task that most humans can do in less than 1 second, supervised learning can probably learn this A-to-B mapping.1 pointTrueFalse

---------is not well fitted for photographic works.a.BMPb.Gifc.JPEGd.PNG

---------is not well fitted for photographic works.a.Gifb.PNGc.JPEGd.BMP

Use the 'show leds' block to design your own icon.Once you are satisfied with your icon, save a snapshot of it and upload the snapshot here.To upload, follow these steps:Click on the paperclip icon 📎 ('Upload File').Click on 'Click to upload or drop file here'.Select your snapshot from the folder where you saved your snapshot.Click on 'UPLOAD'.

Write the code for inserting an Image in a Webpage.Dimensions of the Image will be 300x300.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.