Download and install the PIL python image Library. This library is used to creat
ID: 3571882 • Letter: D
Question
Download and install the PIL python image Library. This library is used to create and/or modify picture (image) files. See the attached image file, animation.gif animation.gif This file is an animated gif file. It was made by creating 30 files in a folder called images. These files were named consecutive names such as pic_01.gif, pic_02.gif, pic_03.gif etc. Then using Gimp, the 30 pictures were loaded as 30 layers in gimp and that was converted to one gif file and saved as an animation. You will need to write a python program to create 30 gif files that will use gimp to produce your own animated gif. Do not have it make little boxes like I did, instead heave it make little circles or triangles.
Explanation / Answer
from graphics import *
from PIL import Image as NewImage
anchorpoint=Point(250,250)
height=500
width=500
image=Image(anchorpoint, height, width) #creates a blank image in the background
win = GraphWin("Red Circle", width, height)
# circle needs center x, y coordinates and radius
n=30
for a in range(1,n+1):
center = Point(250, 250)
radius = a*3
circle = Circle(center, radius)
circle.setFill('red')
circle.setWidth(2)
circle.draw(win)
# saves the current TKinter object in postscript format
win.postscript(file="image.eps", colormode='color')
# Convert from eps format to gif format using PIL
img = NewImage.open("image.eps")
img.save("circle_"+a+".gif", "gif")
# wait, click mouse to go on/exit
win.getMouse()
win.close()
#######that's it#####
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.