Personal tools

[13]PILを使う

画像を動的に拡大,縮小するために,Python Imaging Library(PIL)を利用します

Python Imaging Library(PIL)を使うと,画像を動的に拡大,縮小できます(他のこともできます)。ArchetypesのImageFieldは,引数に画像のサイズを渡すことが出来ます。ATContentTypesでは, 'ATContentTypes/content/image.py' に以下のサイズを定義しています:
   sizes= {'large'   : (768, 768),
           'preview' : (400, 400),
           'mini'    : (200, 200),
           'thumb'   : (128, 128),
           'tile'    :  (64, 64),
           'icon'    :  (32, 32),
           'listing' :  (16, 16),
          }

サイズを「名前」で定義します。たとえば,richdocument_view_previewで「サムネイル」を表示する場所には,以下のようになっています:

  <img tal:replace="structure python:image.tag(scale='thumb')"/>

'image'はImageAttachmentに存在しています。


以下のURLにあるHow Toの翻訳です。

http://plone.org/documentation/tutorial/richdocument/pil

Navigation
Log in


Forgot your password?
 

Powered by Plone, the Open Source Content Management System