def delete(self, save=True): for variation in IMAGE_VARIATIONS.iterkeys(): try: self.storage.delete(self._variation_name(variation)) except NotImplementedError: pass super(ImageFieldFile, self).delete(save)
def _create_variations(self, content): for variation, transforms in IMAGE_VARIATIONS.iteritems(): content.seek(0) io = cStringIO.StringIO() image = Transforms() image.open(content) for transform in transforms: method_name, kwargs = transform if method_name == 'save': kwargs['path'] = io method = getattr(image, method_name) method(**kwargs) if not 'save' in transforms: image.save(io) image_file = ContentFile(io.getvalue()) self.storage.save(self._variation_name(variation), image_file)