# # simple program for image manipulation program # # written by e.bonakdarian nov 2009 # - updated nov 2010 # import Image ##################################################### def Diag(img, pixel_color): # put a diagonal line across the image in the # specified color pix_ar = img.load() # load image into 2D array cols = img.size[0] # number of columns rows = img.size[1] # number of rows for col in range(cols): # our nested loop for row in range(rows): if row == col: pix_ar[col, row] = pixel_color ##################################################### def main(): # load the image from file im = Image.open('c:/pic.jpg') pixel_color = 255, 0, 0 # a red RGB pixel Diag(im, pixel_color) im.show() if __name__ == '__main__': main() raw_input(' to exit')