def testColorScale(name="smokey.gif"): """Loads and draws an image, then applies colorscale to the image and redraws it.""" image = Image(name) print("Close the image window to see the transformation") image.draw() colorscale(image, (randint(0, 255), randint(0, 255), randint(0, 255))) image.draw() image.save(filename="colorscale_" + name)
def testSepia(name="smokey.gif"): """Loads and draws an image, then converts it to sepia and redraws it.""" image = Image(name) print("Close the image window to see the transformation") image.draw() sepia(image) image.draw() image.save(filename="sepia_" + name)
def testPosterize(name="smokey.gif"): """Loads and draws an image, then converts it to black and white and redraws it.""" image = Image(name) print("Close the image window to see the transformation") image.draw() posterize(image, (0, 0, 255)) image.draw() image.save(filename="posterize_" + name)
from images import Image image = Image("smokey.gif") image.draw() print(image.getWidth()) print(image.getHeight()) print(image) print(image.getPixel(0, 0)) image = Image(150, 150) image.draw() blue = (0, 0, 255) y = image.getHeight() // 2 for x in range(image.getWidth()): image.setPixel(x, y - 1, blue) image.setPixel(x, y, blue) image.setPixel(x, y + 1, blue) image.draw() image.save("horizontal.gif")