Python script LCD nokia bitmap

Hello everyone,
I’m new on the forum but it’s been a while since I’m using arduino.
Recently I buyed a LCD display and I needed to convert an image to a bitmap format usable by the pcb8455 library.
So I made this little python script working with images with dimensions 84*48 (I create them with gimp). You can change the dimensions of course if you want to use it with any other sizes.
I imagine it can be usefull so I share it

import Image
import sys

if(len(sys.argv) != 2):
    print 'Usage : "python <image file name>'
    jpg = False
    png = False

    if('jpg' in sys.argv[1] or 'gif' in sys.argv[1]):
        jpg = True
    elif('png' in sys.argv[1]):
        png = True

    if((not png) and (not jpg)):
        print 'Bad image format, use png (or gif, jpg)'

        im =[1])
        tab = []

        for y in range(48/8):
            for x in range(84):
                byte = 0
                for k in range(8):
                        if(im.getpixel((x,y*8+(7-k))) < 100):
                            byte = byte | 1
                        if(im.getpixel((x,y*8+(7-k)))[0] < 100):
                            byte = byte | 1
                    byte = byte << 1                
                byte = byte >> 1

        print '{',
        for i in range(len(tab)):
            print hex(tab[i]),
            if(i != (len(tab)) -1):
                print ',',
        print '}'

ps : sorry for my english I’m french :wink: