Changeset 167:e8352e8ba94a
- Timestamp:
- 08/23/07 15:17:38 (17 months ago)
- Author:
- Tarek Ziad?? <tarek@…>
- Message:
-
merge
- Location:
- cachers
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r142
|
r165
|
|
| 5 | 5 | from StringIO import StringIO |
| 6 | 6 | |
| 7 | | logging.basicConfig(level=logging.DEBUG, |
| 8 | | format='%(asctime)s %(levelname)s %(message)s', |
| 9 | | filename='cached.log', |
| 10 | | filemode='w') |
| | 7 | #logging.basicConfig(level=logging.DEBUG, |
| | 8 | # format='%(asctime)s %(levelname)s %(message)s', |
| | 9 | # filename='cached.log', |
| | 10 | # filemode='w') |
| 11 | 11 | |
| 12 | 12 | console = logging.StreamHandler() |
-
|
r139
|
r165
|
|
| 27 | 27 | def _new_size(image, width, height, scale): |
| 28 | 28 | """calculate new size""" |
| | 29 | if width == -1: |
| | 30 | width = None |
| | 31 | if height == -1: |
| | 32 | height = None |
| 29 | 33 | img_width, img_height = image.size |
| 30 | 34 | if width is None and height is None and scale is None: |
| 31 | 35 | return image.size |
| | 36 | |
| | 37 | if width is not None and height is not None: |
| | 38 | return width, height |
| 32 | 39 | |
| 33 | 40 | if width is not None or height is not None: |
| … |
… |
|
| 49 | 56 | width, height = _new_size(image, width, height, scale) |
| 50 | 57 | |
| 51 | | image.thumbnail((width, height), Image.ANTIALIAS) |
| | 58 | #image.thumbnail((width, height), Image.ANTIALIAS) |
| | 59 | #image.resize((width, height), Image.ANTIALIAS) |
| | 60 | image.load() |
| | 61 | image = image._new(image.im.stretch((width, height), Image.NEAREST)) |
| 52 | 62 | |
| 53 | 63 | data = StringIO() |