Size: 2256
Comment:
|
Size: 312
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= The Problem = Using [http://www.reportlab.org repotlab] and following the instructions from ["PIL and py2exe"]. Still, when {{{ #!python from reportlab.lib.utils import ImageReader im=ImageReader(someCstringIOStream()) }}} raises "cannot identify image file" = Explanation = Reportlab does some different things when importing Image from PIL excerpt from reportlab.lib.utils {{{ #!python class ImageReader: "Wraps up either PIL or Java to get data from bitmaps" def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None #detect which library we are using and open the image if sys.platform[0:4] == 'java': from javax.imageio import ImageIO if type(fileName) is type(''): fp = open(fileName,'rb') else: fp = fileName self._image = ImageIO.read(fp) else: import PIL.Image self._image = PIL.Image.open(fileName) }}} = Solution = Make it dumb. We know: This is not Java, this is Windows. We have PIL, because we use py2exe and ARE responsible to put it into the package. So... {{{ #!python class MyImageReader(ImageReader): """ Kopie des Report-Lab Image Readers, kommt besser mit py2exeter PIL zurande""" def __init__(self, fileName): #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None #änderung: kein Detect oder so, DIES IST WINDOWS # PIL IST VORHANDEN self._image = Image.open(fileName) }}} Image has to be imported and "tuned" as described in ["PIL and py2exe"] HAM2004-08-09 |
Not much to say about me at all.<<BR>><<BR>> Great to be a member of this site.<<BR>><<BR>> I really wish I'm useful at all<<BR>><<BR>> <<BR>><<BR>> Feel free to visit my blog - summoners war hack ([[http://www.wattpad.com/113192113-summoners-war-hack-2015-summoners-war-online-hack|Recommended Web page]]) |
Not much to say about me at all.
Great to be a member of this site.
I really wish I'm useful at all
Feel free to visit my blog - summoners war hack (Recommended Web page)