Sorry-- meant to post to comp.python.image "S. D. Rose" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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' > > >>> bwImg =imageOps.grayscale(img) > >>> bwImg.format > > >>> todb = bwImg.tostring(encoder_name='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 > > > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list