Reputation: 825
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()
Upvotes: 0
Views: 288
Reputation: 5664
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.
Upvotes: 1