Is there something wrong with this code? It doesn't say there are any errors but the 'img' variable never shows at the end.
import Image
import ImageDraw
def main():
b = 4
size = 25
fig_width = size
fig_height = size
white_rgb = (255, 255, 255)
black_rgb = (0, 0, 0)
img = Image.new("RGB", (fig_width, fig_height), white_rgb)
draw = ImageDraw.Draw(img)
for i in range(0, size, 5):
for j in range(0, size, 5):
if i % 2 == j % 2:
draw.rectangle([(j, i), (j + b, i + b)], black_rgb)
img.show()
main()
PIL will try to use the ImageMagick
display
utility orxv
to display images. If it cannot find either, it will fail silently. Try installing theimagemagick
Ubuntu package and then run the script again.