Re: PIL, OFS.Image and HTTPRequest.Fileupload

Katja Suess <[email protected]>
Newsgroups gmane.comp.web.zope.german
Message-ID <[email protected]>
Hi ihr beiden 
danke für eure Antworten
Mit 
im = Image.fromstring('RGB', (10,20), fileupload.read())
folder._setObject(foto_id, OFS.Image.Image(foto_id, title, '', None, ''))
foto = folder._getOb(foto_id)
foto.manage_upload(im.tostring())          
wird ein image angelegt. Offensichtlich nicht mit den richtigen Daten
Aber das ist wohl eher eine Frage an PIL


Andreas Jung-5 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 06.02.2009 10:15 Uhr, Katja Suess wrote:
>> Hi
>> Ich möchte einen Upload von einem Bild anbieten, das dann als OFS.Image
>> gespeichert werden soll.
>> Es soll skaliert hinterlegt werden.
>> Dazu habe ich folgendes versucht. Aber das Ganze passt noch nicht.
>> PIL.Image
>> kann mit einem HTTPRequest.Fileupload offensichtlich nichts anfangen.
>> 
>> from cStringIO import StringIO
>> fileupload = self.request.form.get('file', None)
>> if fileupload:
>>    folder = self.context.datenbank.communityfotos
>>    foto_id = user_id + '-' + str(random.randint(0,999999))
>>    im = Image.fromstring('RGB', (10,20), fileupload.read())
>>    im.thumbnail((10,10))
>>    outFile = StringIO()
>>    im.save(outFile)
>>    folder._setObject(foto_id, OFS.Image.Image(foto_id, title, '', None,
>> ''))
>>    foto = folder._getOb(foto_id)
>>    foto.manage_upload(outFile)
> 
> Übergib manage_upload() die Bilddaten als Binärstring.
> 
> - -aj
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAkmMAdIACgkQCJIWIbr9KYx+LQCg1lUlROmJMsylPc5nIVp0pstf
> NOoAniavoAOzcRgfkFKOpWlTcK+HPRqc
> =kFlK
> -----END PGP SIGNATURE-----
> 
> begin:vcard
> fn:Andreas Jung
> n:Jung;Andreas
> org:ZOPYX Ltd. & Co. KG
> adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
> email;internet:[email protected]
> title:CEO
> tel;work:+49-7071-793376
> tel;fax:+49-7071-7936840
> tel;home:+49-7071-793257
> x-mozilla-html:FALSE
> url:www.zopyx.com
> version:2.1
> end:vcard
> 
> 
> 
> 
> _______________________________________________
> zope mailing list
> [email protected]
> https://mail.dzug.org/mailman/listinfo/zope
> 
> 

-- 
View this message in context: http://n2.nabble.com/PIL%2C-OFS.Image-and-HTTPRequest.Fileupload-tp2282680p2283244.html
Sent from the Zope & Plone - Germany mailing list archive at Nabble.com.



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.