Re: PIL, OFS.Image and HTTPRequest.Fileupload

"Jens W. Klein" <[email protected]>
Newsgroups gmane.comp.web.zope.german
Organization Klein & Partner KEG, BlueDynamics Alliance
Message-ID <1233912244.23253.262.camel@minime>
Am Freitag, den 06.02.2009, 01:15 -0800 schrieb Katja Suess:
> 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))

#wenn ich mich recht erinnere geht das so (ungetested)

     value = StringIO(fileupload.data)
     im = Image.fromstring('RGB', (10,20), value)

>    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)
> 
> Danke für Tipps
> Gruss, Katja
-- 
Jens Klein
Software Architect
Managing Director, General Partner
+43 512 890077

BlueDynamics Alliance        WEB APPLICATIONS,  ZOPE,  PLONE, HOSTING
Klein & Partner KEG          production: concept, development, design
http://bluedynamics.com      consulting: analysis, coaching, training
http://zoplo.com             management: projects, process, community



_______________________________________________
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.