def test_crop(self): with AttachableDescriptor(self.cat_jpeg) as d: # Checking when not modifying stream. ctx = dict() ImageProcessor(crop=(160, 120, 480, 360)).process(d, ctx) ctx = dict() ImageAnalyzer().process(d, ctx) self.assertDictEqual(ctx, { 'content_type': 'image/jpeg', 'width': 320, 'height': 240, })
def test_crop(self): with AttachableDescriptor(self.cat_jpeg) as d: # Checking when not modifying stream. ctx = dict() ImageProcessor(crop=dict( width='50%', height='50%', gravity='center')).process(d, ctx) ctx = dict() WandAnalyzer().process(d, ctx) self.assertDictEqual(ctx, { 'content_type': 'image/jpeg', 'width': 320, 'height': 240, })
class Banner(Image): __pre_processors__ = ImageProcessor(fmt='jpeg', width=300)