Re: setting scaled image troubles
Sebastian Tänzer <[email protected]>
| Newsgroups | gmane.comp.cms.zms.devel |
|---|---|
| Message-ID | <[email protected]> |
Diez,
As far as I understand you're trying to create the thumbnail within a
python script. You don't have to.
Inside your content object create a method (method, not DTML-Method!)
"onChangeObjEvt" with the following code:
<dtml-call "setObjProperty('img',
createThumbnail
(img
=
getObjProperty
('imghighres
',REQUEST
),maxdim
=
getObjProperty
('thumbwidth
',REQUEST),qual=getObjProperty('thumbquality',REQUEST)),lang)">
This one replaces the "img" field (type: image) with a thumbnail from
the image from the imghighres and takes the properties for maxdim and
quality (jpeg quality) from the string fields thumbwidth and
thumbquality.
If you want to just resize the existing image inside field "img"
replace imghighres with img.
Without using different fields:
<dtml-call "setObjProperty('img',
createThumbnail
(img=getObjProperty('imghighres',REQUEST),maxdim=20,qual=95),lang)">
Yours sincerely
Sebastian Tänzer
tänzer media group e.K.
design development consulting
c/o amcm GmbH
Kekuléstr. 39
53115 Bonn
Germany
Tel +49-228-33646-23
Fax +49-228-33646-13
Mobil +49-174-333-7001
E-Mail [email protected]
WWW http://www.taenzer.me
Am 03.02.2009 um 22:41 schrieb Diez B. Roggisch:
> Hi,
>
> I'm trying to create a ZMSGraphic-like custom-object that auto-
> generates
> preview images to embed into the text.
>
> I found more or less everything I need. pil_img_resize, ImageFromData.
>
> But after creating a scaled image, I don't seem to be able to set it
> to
> the custom object as property, let alone invoke getHref on it.
>
> See the below code for a debugging session. Any suggestions?
>
> (Pdb) img = context.getObjProperty("img", request)
> (Pdb) scaled_img = context.pil_img_resize(img, (20, 20))
> (Pdb) scaled_blob = context.ImageFromData(scaled_img['data'])
> (Pdb) p scaled_blob
> <MyImage at >
> (Pdb) p img
> <MyImage at >
> (Pdb) context.setObjProperty("scaled_img", scaled_blob, "ger")
> (Pdb) context.getObjProperty("scaled_img", request)
> ''
>
> Diez
>
>