ryankelley001

JPEG to JPEG2000

Discussion created by ryankelley001 on Dec 28, 2011
Latest reply on Dec 28, 2011 by ryankelley001
I am using PIL to convert .jpg's to .jp2's (for cache) for our mobile devices. I have not seen anything that says PIL supports JPEG2000... however, my script seems to work... the file sizes are smaller, and they show up more clear on the mobile devices (using ArcPad).

The issue is that only some of the cache scales are viewed without error on the mobile device, and I am wondering if I can use the code the way I am, or if I am essentially running into issues since PIL does not "support"  JPEG2000.

Anyone have any experience with this? Is there a better way to convert to .jp2, preferably with Python? Too bad you can't create your cache directly to .jp2.


import Image, os, sys
rootPath = myPath
for (path, dirs, files) in os.walk(rootPath):
    for file in files:
        if file.lower().endswith(".jpg"):
            jpgName = file.replace(".jpg","")
            jpg = Image.open(path + "\\" + file)
            jpg.save(path + "\\" + jpgName + ".jp2", "JPEG")

Outcomes