Annoyance of .gif in Windows 7

Posted in Miscellaneous, Programming on December 29th, 2010 by Jacob

So, I’ve been using Windows 7 for quite some time now, and are generally happy with it. But, for some reason Microsoft has redone their Photo Viewer, and it is no longer possible to view .gif files in it. I don’t know if this was an issue in Windows Vista, as I never used it.

So, instead of finding an alternative photo/image viewer, I wrote a small Python script that converts most image files into .jpg files, as I’m happy enough with Photo Viewer to want to be bothered by finding an alternative :)

Here’s the code for the script:


import Image, sys, os

def convert(infile):
    name, filetype = os.path.splitext(infile)
    outfile = name + ".jpg"
    try:
        im = Image.open(infile)
        if im.mode != "RGB":
            im = im.convert("RGB")
        im.save(outfile, "JPEG")
        print "Succesfully converted", infile, "to", outfile
    except IOError, e:
        print "Cannot convert", infile
        print "Error:", e

if __name__ == "__main__":
    for item in sys.argv[1:]:
        convert(item)
    sys.exit()