Nitro
August 5, 2008, 7:04pm
1
Hello,
is there any function to save an image to a string? I tried this:
import cStringIO
outputStream = cStringIO.StringIO()
img.SaveFile( wx.OutputStream(outputStream), wx.BITMAP_TYPE_PNG )
but it fails. Calling img.GetData() is not what I want because it returns the raw image data and not the image as saved to a file.
-Matthias
Nitro wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed">Hello,
is there any function to save an image to a string? I tried this:
import cStringIO
outputStream = cStringIO.StringIO()
img.SaveFile( wx.OutputStream(outputStream), wx.BITMAP_TYPE_PNG )
but it fails. Calling img.GetData() is not what I want because it returns the raw image data and not the image as saved to a file.
-Matthias
</div>
You might take a look at the img2py utility. You can read a little bit about it here: http://www.blog.pythonlibrary.org/?p=34
And here's the official docs: wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
HTH
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Nitro
August 5, 2008, 7:56pm
4
That did the trick, thank you. I must've overlooked it when I did dir(wx.Image).
-Matthias
···
Am 05.08.2008, 21:49 Uhr, schrieb Robin Dunn <robin@alldunn.com>:
Nitro wrote:
Hello,
is there any function to save an image to a string? I tried this:
import cStringIO
outputStream = cStringIO.StringIO()
img.SaveFile( wx.OutputStream(outputStream), wx.BITMAP_TYPE_PNG )
but it fails.
It's called SaveStream.
Nitro
August 5, 2008, 7:57pm
5
Thanks, didn't think about looking at it.
-Matthias
···
Am 05.08.2008, 21:47 Uhr, schrieb Mike Driscoll <mike@pythonlibrary.org>:
You might take a look at the img2py utility. You can read a little bit about it here: http://www.blog.pythonlibrary.org/?p=34
And here's the official docs: wxPython API Documentation — wxPython Phoenix 4.2.2 documentation