Howdy folks;
I know there's a combination to do this, but I'm not getting it right.
I've got a wxImage object I want to feed directly into a zipfile
object, avoiding any temp files.
zipfile allows the .writestr option, and I can get a string using
img.GetData(), but the string isn't a necessarily the format a JPEG
file needs to be. Is there a way to convert the GetData() string into
a true Jpeg formatted string?
Alternately, I tried passing cStringIO.StringIO(fooImage.GetData()) to
the zipfile.write() method, but it only likes a filepath to the file,
and not the file object itself.
Any way to avoid creating a temp file? I'm guessing a conversion
routine of some sort for the GetData() value?
···
--
-----------------------------
e y e p u l p
-----------------------------
Howdy folks;
I know there's a combination to do this, but I'm not getting it right.
I've got a wxImage object I want to feed directly into a zipfile
object, avoiding any temp files.
zipfile allows the .writestr option, and I can get a string using
img.GetData(), but the string isn't a necessarily the format a JPEG
file needs to be. Is there a way to convert the GetData() string into
a true Jpeg formatted string?
Alternately, I tried passing cStringIO.StringIO(fooImage.GetData()) to
the zipfile.write() method, but it only likes a filepath to the file,
and not the file object itself.
Any way to avoid creating a temp file? I'm guessing a conversion
routine of some sort for the GetData() value?
You can probably do it with PIL, but for now there isn't a way to do it directly with wx.Image as I haven't fully wrapped wxOutputStream to be interchangeable with Python file-like objects...
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
and just use zipfile.write(), then delete the temp file. It's not too
inefficient, and seemed healthier than adding PIL to the mix for this
particular issue.
Thanks again.
···
On 1/24/07, Robin Dunn <robin@alldunn.com> wrote:
EyePulp wrote:
> Howdy folks;
> I know there's a combination to do this, but I'm not getting it right.
> I've got a wxImage object I want to feed directly into a zipfile
> object, avoiding any temp files.
>
> zipfile allows the .writestr option, and I can get a string using
> img.GetData(), but the string isn't a necessarily the format a JPEG
> file needs to be. Is there a way to convert the GetData() string into
> a true Jpeg formatted string?
>
> Alternately, I tried passing cStringIO.StringIO(fooImage.GetData()) to
> the zipfile.write() method, but it only likes a filepath to the file,
> and not the file object itself.
>
> Any way to avoid creating a temp file? I'm guessing a conversion
> routine of some sort for the GetData() value?
>
You can probably do it with PIL, but for now there isn't a way to do it
directly with wx.Image as I haven't fully wrapped wxOutputStream to be
interchangeable with Python file-like objects...
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
--
-----------------------------
e y e p u l p
-----------------------------