Hello all. I have a staticbitmap, and I want to save the image from it to a
mysql database. Here's how I'm trying to do it. self.liveVideo is the
static bitmap. I do a GetBitmap() and place the reference to the image into
x. Then I try to do a x.SaveFile(). When I give it a filename, then all
works fine. But I don't want to place it on the filesystem, I want to take
it and place it into a MySQLdb Insert statement to place it into a table.
The 4th line, where I list to save it into out2db doesn't work. Can anyone
give me any pointers?
I looked into a .GetData() and also .ConvertToImage(), but I need to have this image be formatted as a JPEG, so I don't think that either of these do it. Also, trying the .ConvertToImage() then the .GetData(), I tried to take that result and pass it to my INSERT sql line via MySQLdb, and it returned an error that the input to the BLOB field was too large.
Hello all. I have a staticbitmap, and I want to save the image from it to a
mysql database. Here's how I'm trying to do it. self.liveVideo is the
static bitmap. I do a GetBitmap() and place the reference to the image into
x. Then I try to do a x.SaveFile(). When I give it a filename, then all
works fine. But I don't want to place it on the filesystem, I want to take
it and place it into a MySQLdb Insert statement to place it into a table.
The 4th line, where I list to save it into out2db doesn't work. Can anyone
give me any pointers?
I looked into a .GetData() and also .ConvertToImage(), but I need to have
this image be formatted as a JPEG, so I don't think that either of these do
it. Also, trying the .ConvertToImage() then the .GetData(), I tried to take
that result and pass it to my INSERT sql line via MySQLdb, and it returned
an error that the input to the BLOB field was too large.
I really appreciate it. Thanks for any help!!
-Dave
---------------------------------------------------------------------
To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org
I have never done it using pyton, but several times w/ PHP.
I think you have to save the content of x as is into your blob. Along
you have to store Mime Type and maybe even size (though I think that
is not needed outside a web browser, though).
When you want to resore the jpg you have to read the x in again and
then use the wx.BITMAP_TYPE_JPEG method to tell it that it is a bitmap
of type jpg (data you should have stored in the mime_type field).
A PHP way to do it is here: Radar – O’Reilly
I know how to put a .JPEG graphic file into a database, I've done that
before (Although that buggered me about a year ago) -- what I thought would
be easy but I don't seem to see is how to get the image out of the
wxStaticBitmap object, which I think it needs to be encoded back into a jpg.
But, what I don't want to do is have to save it to the file-system and
re-open it to just because I don't know how to extract the data-JPEG-Encoded
from the StaticBitmap to a variable so I can then insert into the database.
-Dave
"the_shelter" <pdftex@the-shelter.de> wrote in message
news:4510013651.20060429111200@the-shelter.de...
···
Hello Dave,
Saturday, April 29, 2006, 6:18:17 AM, you wrote:
> Hello all. I have a staticbitmap, and I want to save the image from
it to a
> mysql database. Here's how I'm trying to do it. self.liveVideo is
the
> static bitmap. I do a GetBitmap() and place the reference to the
image into
> x. Then I try to do a x.SaveFile(). When I give it a filename, then
all
> works fine. But I don't want to place it on the filesystem, I want to
take
> it and place it into a MySQLdb Insert statement to place it into a
table.
> The 4th line, where I list to save it into out2db doesn't work. Can
anyone
> give me any pointers?
> I looked into a .GetData() and also .ConvertToImage(), but I need to
have
> this image be formatted as a JPEG, so I don't think that either of
these do
> it. Also, trying the .ConvertToImage() then the .GetData(), I tried
to take
> that result and pass it to my INSERT sql line via MySQLdb, and it
returned
> an error that the input to the BLOB field was too large.
> I really appreciate it. Thanks for any help!!
> -Dave
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail:
> wxPython-users-help@lists.wxwidgets.org
I have never done it using pyton, but several times w/ PHP.
I think you have to save the content of x as is into your blob. Along
you have to store Mime Type and maybe even size (though I think that
is not needed outside a web browser, though).
When you want to resore the jpg you have to read the x in again and
then use the wx.BITMAP_TYPE_JPEG method to tell it that it is a bitmap
of type jpg (data you should have stored in the mime_type field).
A PHP way to do it is here: Radar – O’Reilly
Hello all. I have a staticbitmap, and I want to save the image from it to a
mysql database. Here's how I'm trying to do it. self.liveVideo is the
static bitmap. I do a GetBitmap() and place the reference to the image into
x. Then I try to do a x.SaveFile(). When I give it a filename, then all
works fine. But I don't want to place it on the filesystem, I want to take
it and place it into a MySQLdb Insert statement to place it into a table.
The 4th line, where I list to save it into out2db doesn't work. Can anyone
give me any pointers?
Hooking the wxOutputStream to be able to write to Python file-like objects is still on the ToDo list. For now you'll either need to save it to a file and then open the file and read the data from it, or you can get the RBG bytes from the wx.Image and then use that with PIL to get the jpeg bytes.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!