HI, I am very very new to python and I am tring to work on a homework assignment. I know that you only give help to those who help themselves, so I am hoping that you can help me. I have to write two python programs, one that will take an existing image and scale it to whatever size is defined by the variable "n". I think I have that part working here is my program:

def scaleUp(img, n):
width, height = img.size
newWidth = n * width
newHeight = n * height
newimg = Image.new('RGB', (newWidth, newHeight))
for i in range(newWidth):
for j in range(newHeight):
color = img.getpixel((i//n, j//n))
newimg.putpixel((i, j), color)
return newimg


The second program that I have to write is on that will take an image an return a tile of that image by the value of "n^2". I am at a loss of where to start for this. Any help is appreciated.

Thanks.

We are talking PIL. 'n^2' ??? All I can think of is that you may want to average the color of one 4x4 area rather than one 2x2 area.