Hello
I am attempting to put together a package that uses python2.3 under the corresponding version of cx_freeze on Windows 2K. My test module is: import cStringIO, StringIO import Image import WmfPlugin def convert(wmfdata): im = Image.open(cStringIO.StringIO(wmfdata)) x,y = im.size smallest = min(x,y) scale = int(2*1728.0/smallest + 0.99) im.size = x*scale, y*scale im.load() if x > y: im = im.rotate(90) out = StringIO.StringIO() im.save(out,'PNG') return out.getvalue() if __name__ == '__main__': d1 = open('wind.wmf','rb').read() d2 = convert(d1) open('wind.png','wb').write(d2) When run interactively from python23 it works really well but when frozen I get the following error: Traceback (most recent call last): File "C:\Src\1_cx_Freeze-3.0.3\initscripts\console.py", line 27, in ? exec code in m.__dict__ File "wmf2png.py", line 30, in ? File "wmf2png.py", line 20, in convert If x > y: File "C:\Python23\lib\site-packages\PIL\Image.py", line 1295, in save Save_handler = SAVE[string.upper(format)] # unknown format KeyError: 'PNG' The traceback line numbers for some reason are not showing the correct error location in the module: => im.save(out,'PNG') I added debugging into Image.py to print out SAVE before the exception and find: {'WMF': <function _save at 0x0091DC70>} Running the unfrozen module interactively SAVE has entries for TIFF, PNG, GIF, WMF etc. The environment is a new Win2K + SP4 with the latest python2.3 code running under VMWare on an XP box. I have tried various ways of attempting to register the PNG module without success. Any thoughts as to how to get around this problem would be much appreciated. Thanks Colin Brown PyNZ Ps: 1. I am using 2.3 as there appears to be no later version of the WmfPlugin module. 2. Although there are other WMF converters available, the PIL module is one of the few that handles the in-house written WMF files I have to convert :-)
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig