0

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()
UnworthyToast
  • 825
  • 5
  • 11
  • 21

1 Answers1

1

PIL will try to use the ImageMagick display utility or xv to display images. If it cannot find either, it will fail silently. Try installing the imagemagick Ubuntu package and then run the script again.

Tim Pierce
  • 5,514
  • 1
  • 15
  • 31
  • I downloaded the ImageMagick.tar.gz but I can't figure out how to install it. I don't know if this makes a difference, but I am not using Terminal to run the program. I'm using a free IDE. – UnworthyToast Dec 10 '13 at 17:02
  • Ubuntu supplies an `imagemagick` package that you can install via the Ubuntu Software Center, or `apt-get install imagemagick` if you prefer. – Tim Pierce Dec 10 '13 at 17:03