[Checkins] SVN: z3c.image/trunk/ added resize after crop
Oliver Petznick
oliver at mopa.at
Fri Nov 9 04:30:56 EST 2007
Log message for revision 81629:
added resize after crop
Changed:
U z3c.image/trunk/CHANGES.txt
U z3c.image/trunk/setup.py
U z3c.image/trunk/src/z3c/image/proc/BROWSER.txt
U z3c.image/trunk/src/z3c/image/proc/browser.py
-=-
Modified: z3c.image/trunk/CHANGES.txt
===================================================================
--- z3c.image/trunk/CHANGES.txt 2007-11-09 00:58:54 UTC (rev 81628)
+++ z3c.image/trunk/CHANGES.txt 2007-11-09 09:30:55 UTC (rev 81629)
@@ -2,9 +2,15 @@
Changes for z3c.image
=====================
-2007/06/21 0.1.1:
+2007/11/09 0.1.3:
=================
+- added resize after crop
+
+
+2007/06/21 0.1.2:
+=================
+
- Prevent ProcessableImage from crashing if image type is unknown.
If the type is unknown to Zope it is maybe known to PIL.
Modified: z3c.image/trunk/setup.py
===================================================================
--- z3c.image/trunk/setup.py 2007-11-09 00:58:54 UTC (rev 81628)
+++ z3c.image/trunk/setup.py 2007-11-09 09:30:55 UTC (rev 81629)
@@ -2,7 +2,7 @@
setup(
name = "z3c.image",
- version = "0.1.2",
+ version = "0.1.3",
author = "Zope Contributors",
author_email = "office at mopacreative.com",
description = "Image utils for zope3",
Modified: z3c.image/trunk/src/z3c/image/proc/BROWSER.txt
===================================================================
--- z3c.image/trunk/src/z3c/image/proc/BROWSER.txt 2007-11-09 00:58:54 UTC (rev 81628)
+++ z3c.image/trunk/src/z3c/image/proc/BROWSER.txt 2007-11-09 09:30:55 UTC (rev 81629)
@@ -59,6 +59,7 @@
1. rotate
2. resize
3. crop
+ 4. after crop resize
If we supply not values the original image is returned.
@@ -77,13 +78,25 @@
>>> getImageInfo(browser.contents)
('image/jpeg', 10, 10)
+Crop top left 10x10px out of the image and resize it to 5x5px.
+ >>> browser.open('http://localhost/flower.jpg/@@processed?' +
+ ... 'local.crop.h=10&' +
+ ... 'local.crop.w=10&' +
+ ... 'local.crop.x=0&' +
+ ... 'local.crop.y=0&' +
+ ... 'after.size.w=5&' +
+ ... 'after.size.h=5&'
+ ... )
+ >>> getImageInfo(browser.contents)
+ ('image/jpeg', 5, 5)
+
We can use 'If-Modified-Since' in the request and get a 304 status.
>>> browser.addHeader('If-Modified-Since',browser.headers.getheader('Last-Modified'))
>>> browser.open('http://localhost/flower.jpg/@@resized')
Traceback (most recent call last):
...
- HTTPError: HTTP Error 304: Not Modified
+ httperror_seek_wrapper: HTTP Error 304: Not Modified
TODO: more tests here
Modified: z3c.image/trunk/src/z3c/image/proc/browser.py
===================================================================
--- z3c.image/trunk/src/z3c/image/proc/browser.py 2007-11-09 00:58:54 UTC (rev 81628)
+++ z3c.image/trunk/src/z3c/image/proc/browser.py 2007-11-09 09:30:55 UTC (rev 81629)
@@ -58,8 +58,12 @@
self.cropW = self.request.form.get('local.crop.w',None)
self.cropY = self.request.form.get('local.crop.y',None)
self.cropH = self.request.form.get('local.crop.h',None)
+
+ self.afterSizeW = int(self.request.form.get('after.size.w',0))
+ self.afterSizeH = int(self.request.form.get('after.size.h',0))
self.size = (self.width,self.height)
+ self.afterSize = (self.afterSizeW,self.afterSizeH)
def _process(self):
pimg = IProcessableImage(self.context)
@@ -78,6 +82,8 @@
int(self.cropX) + int(self.cropW),
int(self.cropY) + int(self.cropH))
pimg.crop(self.croparea)
+ if self.afterSizeW is not 0 and self.afterSizeH is not 0:
+ pimg.resize(self.afterSize)
return pimg.process()
def processed(self):
More information about the Checkins
mailing list