def after_transform(self, context): finish_callback = functools.partial(self.finish_request, context) if context.modules.filters and context.request.filters: self.apply_filters(filters_module.create_instances(context, context.modules.filters, context.request.filters), finish_callback) else: finish_callback()
def after_transform(self, context): finish_callback = functools.partial(self.finish_request, context) if context.modules.filters and context.request.filters: self.apply_filters( filters_module.create_instances(context, context.modules.filters, context.request.filters), finish_callback) else: finish_callback()
def topic(self): conf = Config() req = RequestParameters(quality=100) ctx = Context(None, conf, None) ctx.request = req filters = [Filter] compile_filters(filters) filter_instances = create_instances(ctx, filters, "quality(10)") filter_instances[0].run_filter() return ctx.request.quality
def callback(normalized, buffer): if buffer is None: self._error(404) return new_crops = None if normalized and should_crop: actual_width, actual_height = self.engine.size if not width and not height: actual_width = self.engine.size[0] actual_height = self.engine.size[1] elif width: actual_height = self.engine.get_proportional_height(self.engine.size[0]) elif height: actual_width = self.engine.get_proportional_width(self.engine.size[1]) new_crops = self.translate_crop_coordinates( self.engine.source_width, self.engine.source_height, actual_width, actual_height, crop_left, crop_top, crop_right, crop_bottom ) context = dict( loader=self.loader, engine=self.engine, storage=self.storage, detectors=self.detectors, normalized=normalized, buffer=buffer, should_crop=should_crop, crop_left=new_crops and new_crops[0] or crop_left, crop_top=new_crops and new_crops[1] or crop_top, crop_right=new_crops and new_crops[2] or crop_right, crop_bottom=new_crops and new_crops[3] or crop_bottom, fit_in=fit_in, should_flip_horizontal=horizontal_flip, width=width, should_flip_vertical=vertical_flip, height=height, halign=halign, valign=valign, smart=should_be_smart, image_url=image, extension=extension, filters=[], focal_points=[] ) self.engine.load(buffer, extension) if meta: context['engine'] = JSONEngine(self.engine, image) if self.filters and filters: context['filters'] = filters_module.create_instances(self.engine, self.filters, filters) Transformer(context).transform() if meta: content_type = 'text/javascript' if options.META_CALLBACK_NAME else 'application/json' else: content_type = CONTENT_TYPE[context['extension']] self.set_header('Content-Type', content_type) results = context['engine'].read(context['extension']) self.write(results) self.finish()