Python Image Library

S

S. D. Rose

I have a question about PIL.

I get a 50k photo from a MySQL table, convert it to grey-scale, do some
rotations, etc. Then I want to put it back. It seems that after I do the
greyscale, it converts from 'JPEG' to 'RAW'. Can anyone tell me how I
convert the image back to 'JPEG' and then insert the photo into the MySQL
database? I've tried .tostring('jpeg') but that told me it couldn't load the
jpeg encoder.

My steps are here:
import MySQLdb
import array, cStringIO
import Image, ImageOps
con = MySQLdb(db='', host='', user='', passwd='')
cur = con.cursor()
cur.execute('SELECT photo FROM photos')
result = cur.fetchone()
photo = result[0].tostring()
colorImg = Image.open(cStringIO.StringIO( photo))
colorImg.show() # Shows a color image on the Win32 screen
img.format
'JPEG'
TRACEBACK ...
IOError: encoder JPEG not available.
Any help telling me how to take the bwImg image (not the PIL object) and
placing it back into a MySQL database would be highly appreciated!

Thanks!
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top