import math
import numpy as np
import PIL.Image as Img

def import_img(filename, show=False):
    img = Img.open(filename)
    width, height = img.size

    if(show):
        Img.show(img)

    ptr = open("output.txt", "w")
    ptr.write(str(width) + " " + str(height))
    ptr.write("\n")
    for w in range(0,width,10):
        for h in range(0,height,10):
            (red, green, blue) = img.getpixel((w,h))
            ptr.write(str(red) + "," + str(green) + "," + str(blue))
            if(h != height-1):
                ptr.write(" ")
        ptr.write("\n")

    print("Successfully parsed image '", filename, "'")
    ptr.close()

import_img("stone.bmp")