[reportlab-users] load Image() from embedded python
michael at redmule.com
Sat Feb 8 12:54:32 EST 2014
As noted in my previous reply I was able to make this work great with the
Now I'm doing something like this, and getting the exception below. Any
canvas.drawImage(StringIO('embedded stuff'), ...)
I would be really helpful to be able to embed these things.
I'm using reportlab 3.0a1 BTW.
line 920, in drawImage
imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
line 2086, in __init__
ext = os.path.splitext(source).lower()
File "c:\dev\virtenvs\oldworldblack\lib\ntpath.py", line 190, in splitext
return genericpath._splitext(p, sep, altsep, extsep)
File "c:\dev\virtenvs\oldworldblack\lib\genericpath.py", line 91, in _splitext
sepIndex = p.rfind(sep)
AttributeError: StringIO instance has no attribute 'rfind'
On 1/29/2014 1:47 AM, Andy Robinson wrote:
> I think that everywhere we accept a filename, we also accept a
> file-like object. So you could store it as some kind of escaped
> binary string in your source code, then wrap it in a StringIO and pass
> that to the platypus Image.
> I'm not in a programming environment now but if this is not clear we
> can post a code snippet later in the day...
> - Andy
> On 29 January 2014 00:50, Michael Hipp <michael at redmule.com> wrote:
>> In the reportlab.platypus Image flowable, is it possible to load the image
>> from an image embedded as binary in the python code? The only api for Image
>> seems to depend on a filename.
>> I'd prefer not to have to lug around things like logos and icons with my
>> reportlab-users mailing list
>> reportlab-users at lists2.reportlab.com
More information about the reportlab-users