Binary blobs to jpeg

2007-07-16 Thread jayharvard1
Hello All.
I'm trying to create jpegs out of data that is stored in a binary blob
format in an RDBMS (MS Access). I've tried writing the jpeg directly:

while not rs.EOF:
 op = file(imgdir + "\\" + pic,"w")
 print >> op, rs.Fields[3].Value
 ##where rs.Fields[3].Value is the data in the blob from Access.

When I try to write out this file, the jpeg doesn't turn out.
Strangely, some of the colors partially render. You can see some
outlines and backgrounds, but the full picture doesn't show. Most
jpegs, however, show nothing (in an windows preview).

I then tried opening the image with PIL.Image, with something like
this:

cmd.CommandText = sql
rs=cmd.Execute()[0]
while not rs.EOF:
im = Image.open(StringIO.StringIO(rs.Fields[3].Value))
im.save("c:/projects/temp.jpg", 'JPEG', quality=90,progressive=1)



This is the error I get, I believe at the Image.open() call:
Traceback (most recent call last):
  File "", line 97, in run
  File "C:\Python25\Lib\bdb.py", line 366, in run
exec cmd in globals, locals
  File "C:\Projects\scripts\main.py", line 25, in 
xdb.doImageTbl(db)
  File "C:\Projects\scripts\thunder.py", line 86, in doImageTbl
im = Image.open(StringIO.StringIO(rs.Fields[3].Value))
  File "C:\Python25\lib\site-packages\PIL\Image.py", line 1916, in
open
raise IOError("cannot identify image file")
IOError: cannot identify image file


For a little further information, I was able to accomplish this task
in C#/.Net. A direct write to a file stream produced the exact jpeg
image. So I know the data is not corrupt. I would like to avoid using
the C#/.Net solution if possible.

Any ideas what I'm doing wrong? Any help would be greatly appreciated.

BTW, I'm using Python 2.5 and PIL 1.1.6 on a WinXp box.

Thanks,
jeh

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Binary blobs to jpeg

2007-07-16 Thread jayharvard1
> Have you tried to open the file in "wb" mode?
>
> HTH,
>
> --
> Carsten Haesehttp://informixdb.sourceforge.net

The data is coming from a record set selection from the Access
database. I guess I could write the data to a temp file and open that
file handle with the "wb" mode. But, no, I haven't tried that.

jeh

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is hostmonster any good for hosting python?

2007-10-11 Thread jayharvard1
On Oct 10, 1:27 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> According to hostmonster's list of features, they do support python.
> Does anybody have any experience with hostmonster?

I'm using host monster to run my html-only site. However, I want to
add some python cgi, and I'd prefer to extend that to the Django
framework. I've had some issues getting cgi support. I've IM'd with a
tech rep and all they could tell me is that "yes, they do support
python cgi." From what I've seen, they don't have the mod_python
module installed for Apache. Without mod_python, I don't think you can
install Django. Not sure about other pythonic web frameworks.

Outside of the cgi support, host monster has been pretty good to work
with. They have a pretty slick control panel. Also, they use CentOs 4
and an older version of python.

HTH,
J

-- 
http://mail.python.org/mailman/listinfo/python-list