Zope-Product: superImageContainer

Frank Rossi <[email protected]>
Newsgroups gmane.comp.cms.zms.devel
Message-ID <[email protected]>
Hello,

there is an ongoing discussion about image manipulation in ZOPE/ZMS in  
this forum.

As a everyday need for a developer to get images right I wrote my own  
product to solve
this problem. I use it in all my projects, since that it's very easy  
to manipulate images to
almost any needs... It's far away from beeing perfect, at least it  
works ;-)

I'm happy to give a litte bit back to the open-source community I  
profited over years.

http://dev.telesma.com/exchange/superImageContainer.zip

Provide any feedback you like - like to hear from you.

cheers
Frank Rossi

ps. sorry, for my poor english...




superImageContainer Product for ZOPE
Version 1.0

Brief Description:
This product will solve most image manipulation needs in the life of a  
Zope developer...

Basic Function:
This product will deliver for the transfered image object the matching  
image out of the
superImageContainer instance. First case: If it doesn't exist in the  
container folder,
it creates one using PIL. Second case: If the modification time of the  
transfered image object
is greater than the one already created in container, the old one is  
erased and a new one is
created.

Features:
SCALE:  Scales proportionally to the given size.
CROP:  Scales to the given size and crops the image centered or  
centered:top.
FIT:  Scales to the given size and expands the image with a defined  
background color.
MASK:  Scales the image to the size of the mask and masks the image  
(advanced!)
WATERMARK:  Applies a watermark PNG to the image. Options are  
centered, scale, tile, bottomright, additional offset adjustment and  
opacity.

Zope Tabs:
PROPERTIES: this is the main function tab. Presets are done here.
DELETE: Will delete all image files in the instance folder except the  
repository folder.
VIEW: Will not work anymore because of the object parameter. Doesn't  
matter...

Requirements:
Will work on any Zope version. Hope so;-)
PIL (PythonImagingLibrary) is needed.
ZMS 2.11 is not tested. Perhaps there is a conflict with  
meta_type=['ZMSCustom'].

Installation:
- Put the superImageContainer folder in the products directory of your  
zope instance and restart.
- Import the test_superImageContainer.zexp (this holds some examples)  
and you will get an idea how it works.

Known Issues:
- The superImageContainer will only accept JPG as file input format,  
otherwise you will get an IOError.
- The size of the original image must be greater than the generated  
image, otherwise you will get an IOError.

To-Do List:
- Option for ExtFile-Images instead of Zope-Images. This will keep the  
ZODB small. Another advantage of
   ExtFile is the possibility to serve the images completely with  
Apache through a subdomain!




Zope Usage Example:
<dtml-in expr="imagesfolder.objectValues()">
	<dtml-let bild=sequence-item>
		<div><dtml-var expr="images_scale.index_html(bild)"></div>
	</dtml-let>
</dtml-in>


ZMS Usage Example:
<dtml-in "getObjChildren('example_image',REQUEST)">
	<dtml-let number=sequence-number>
		<dtml-if "number==1">
			<dtml-let bild=sequence-item>
				<dtml-if bild>
				<dtml-let bildname="getObjProperty('bild',REQUEST)">
					<a href="<dtml-var "bildname.getHref(REQUEST)">" title="">
				</dtml-let>
				<dtml-with expr="superImageContainer_Instance.index_html(bild,  
REQUEST, 'bild')">
				<img src="&dtml-absolute_url;" alt="" style="width:&dtml- 
width;px;height:&dtml-height;px;" />
				</dtml-with>
					</a>
				</dtml-if>
			</dtml-let>
		</dtml-if>
	</dtml-let>
</dtml-in>



telesma medialab  ::  interaktive medien. webdesign. fotografie.
mittelstrasse 5  ::  de-68169 mannheim
fon	+49-(0)621-3072724
fax	+49-(0)621-3072725
cell	+49-(0)173-1464133
web    http://www.telesma.com
telesma-logo.gif (image/gif, 2.6 KB) - not displayed
smime.p7s (application/pkcs7-signature, 2.4 KB) - not displayed
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.