w, h = img.width, img.height pixels = {} for y = 0, h-1 do for x = 0, w-1 do pixels[y*w+x+1] = img.getInt(w-1-x, h-1-y) end end