Images are grids of pixels. The more pixels in an image, the better the quality of the image. Pixels are represented as a tuple of three numerical values- red, green, and blue (RBG). These values encode the color of the pixel. RGB values go from 0-255 with (0, 0, 0) being black and (255, 255, 255) being white. The lower the number is, the darker the color.

Pixels are located by (x, y) coordinates on the grid.

To loop through all pixels in the image row by row, use a double for loop:

for y in range (0, image.height):

for x in range (0, image.width):

To loop through all pixels column by column, use a double for loop also:

for x in range (0, image.width):

for y in range (0, image.height):

To create a new image with size of an existing image:

image = SimpleImage(filename)

width = image.width

height = image.height

out = SimpleImage.blank(width, height)

To set pixels of the new image to a pixel of the old image:

image = SimpleImage(filename)