comparison montage/formatters.py @ 2:4b8aa9b0a45b

montage actually does something now
author k0s <k0scist@gmail.com>
date Fri, 25 Dec 2009 03:59:26 -0500
parents b7348ffe5b46
children d60a5ffbf4f4
comparison
equal deleted inserted replaced
1:c5d30bfd032e 2:4b8aa9b0a45b
1 import mimetypes
1 from decoupage.formatters import All 2 from decoupage.formatters import All
2 3
3 class Montage(All): 4 class Images(object):
5 """list of images"""
4 6
5 def __init__(self, arg): 7 def __init__(self, arg):
6 # XXX dummy arg 8 if 'x' in arg:
7 self.match = [ "*.jpg", "*.png", ] 9 width, height = [ i.strip() for i in arg.split('x', 1) ]
8 # XXX should really filter on mimetype 10 self.width = width or None
11 self.height = height or None
12 else:
13 self.width = self.height = None
9 14
10 def __call__(self, request, data): 15 def __call__(self, request, data):
11 All.__call__(self, request, data) 16 data['width'] = self.width
17 data['height'] = self.height
18
19 # filter out non-images
20 _files = []
21 for f in data['files']:
22 mimetype = mimetypes.guess_type(f['name'])[0]
23 if mimetype and mimetype.split('/')[0] == 'image':
24 _files.append(f)
25 data['files'] = _files
26