How about if you do something like:

from cStringIO import StringIO
tmp = StringIO()
im.save(tmp, 'jpeg')
tmp.seek(0)
thisImage.update_record(thumb=db.Images.thumb.store(tmp, filename=
'thumbnail.jpg'))

Anthony

On Friday, September 7, 2012 12:07:27 PM UTC-4, BlueShadow wrote:
>
> Traceback (most recent call last):
>   File "F:\Website\web2py\gluon\restricted.py", line 209, in restricted
>     exec ccode in environment
>   File "F:/Website/web2py/applications/testthumb/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/testthumb/controllers/default.py>, 
> line 128, in <module>
>   File "F:\Website\web2py\gluon\globals.py", line 185, in <lambda>
>     self._caller = lambda f: f()
>   File "F:/Website/web2py/applications/testthumb/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/testthumb/controllers/default.py>, 
> line 121, in newImage
>     makeThumbnail(dbtable,form.vars.id,(200,200))
>   File "F:/Website/web2py/applications/testthumb/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/testthumb/controllers/default.py>, 
> line 106, in makeThumbnail
>     thisImage.update_record(thumb=db.Images.thumb.store(im, 
> filename='thumbnail.jpg'))
>   File "F:\Website\web2py\gluon\dal.py", line 8442, in store
>     shutil.copyfileobj(file, dest_file)
>   File "C:\Python27\lib\shutil.py", line 48, in copyfileobj
>     buf = fsrc.read(length)
>   File "C:\Python27\lib\site-packages\PIL\Image.py", line 512, in __getattr__
>     raise AttributeError(name)
> AttributeError: read
>
>
> that was the error message
>
>
>
> On Friday, September 7, 2012 5:57:09 PM UTC+2, Anthony wrote:
>>
>> Yes, I see a message was deleted -- don't know who deleted it. Can you 
>> post the error again?
>>
>> On Friday, September 7, 2012 11:41:05 AM UTC-4, BlueShadow wrote:
>>>
>>> I was referring to paolos post
>>> your solution gives me just the error message I don't understand 
>>> Anthony. I posted the error message before but it got somehow deleted. 
>>>
>>> On Friday, September 7, 2012 5:38:15 PM UTC+2, Anthony wrote:
>>>>
>>>> On Friday, September 7, 2012 11:22:41 AM UTC-4, BlueShadow wrote:
>>>>>
>>>>> I tried your solution and it just leaves the thumb field empty and no 
>>>>> thumbnail is created in the upload folder.
>>>>>
>>>>
>>>> Are you referring to Paolo's solution or this one:
>>>>
>>>> thisImage.update_record(thumb=db.Images.thumb.store(im, filename=
>>>> 'thumbnail.jpg'))
>>>>
>>>> and how did you get this Database view I really like that^^
>>>>
>>>>
>>>> Are you talking about the image Paolo attached? That's just the Chrome 
>>>> developer tools (hit F12 in Chrome to open it).
>>>>
>>>> Anthony
>>>>
>>>

-- 



Reply via email to