def to_context(self, detectors=None, ignore_detector_error=False): if detectors is None: detectors = [] ThreadPool.reset() self.engine = MockEngine((self.source_width, self.source_height)) flip_horizontally = flip_vertically = False if self.target_width != "orig": flip_horizontally = self.target_width < 0 self.target_width = abs(self.target_width) if self.target_height != "orig": flip_vertically = self.target_height < 0 self.target_height = abs(self.target_height) importer = Importer(None) importer.detectors = detectors importer.storage = NoStorage config = Config() config.IGNORE_SMART_ERRORS = ignore_detector_error ctx = Context(server=None, config=config, importer=importer) ctx.modules.engine = self.engine ctx.request = RequestParameters( buffer=None, debug=False, meta=self.meta, crop={ "left": self.crop_left, "top": self.crop_top, "right": self.crop_right, "bottom": self.crop_bottom, }, adaptive=self.adaptive, full=self.full, fit_in=self.fit_in, horizontal_flip=flip_horizontally, vertical_flip=flip_vertically, width=self.target_width, height=self.target_height, halign=self.halign, valign=self.valign, focal_points=self.focal_points, smart=True, extension="JPEG", filters=[], quality=80, image="some.jpeg", stretch=self.stretch, ) ctx.request.engine = self.engine ctx.request.engine.extension = ".jpeg" return ctx
def to_context(self, detectors=[], ignore_detector_error=False): self.engine = MockEngine((self.source_width, self.source_height)) flip_horizontally = self.target_width < 0 flip_vertically = self.target_height < 0 self.target_width = self.target_width == "orig" and "orig" or abs( self.target_width) self.target_height = self.target_height == "orig" and "orig" or abs( self.target_height) importer = Importer(None) importer.detectors = detectors importer.storage = NoStorage config = Config() config.IGNORE_SMART_ERRORS = ignore_detector_error ctx = Context(server=None, config=config, importer=importer) ctx.modules.engine = self.engine ctx.request = RequestParameters(buffer=None, debug=False, meta=self.meta, crop={ 'left': self.crop_left, 'top': self.crop_top, 'right': self.crop_right, 'bottom': self.crop_bottom }, adaptive=self.adaptive, full=self.full, fit_in=self.fit_in, horizontal_flip=flip_horizontally, vertical_flip=flip_vertically, width=self.target_width, height=self.target_height, halign=self.halign, valign=self.valign, focal_points=self.focal_points, smart=True, extension="JPEG", filters=[], quality=80, image="some.jpeg") ctx.request.engine = self.engine ctx.request.engine.extension = ".jpeg" return ctx
def to_context(self, detectors=[], ignore_detector_error=False): self.engine = MockEngine((self.source_width, self.source_height)) flip_horizontally = self.target_width < 0 flip_vertically = self.target_height < 0 self.target_width = self.target_width == "orig" and "orig" or abs(self.target_width) self.target_height = self.target_height == "orig" and "orig" or abs(self.target_height) importer = Importer(None) importer.detectors = detectors importer.storage = NoStorage config = Config() config.IGNORE_SMART_ERRORS = ignore_detector_error ctx = Context(server=None, config=config, importer=importer) ctx.modules.engine = self.engine ctx.request = RequestParameters( buffer=None, debug=False, meta=self.meta, crop={ 'left': self.crop_left, 'top': self.crop_top, 'right': self.crop_right, 'bottom': self.crop_bottom }, adaptive=self.adaptive, full=self.full, fit_in=self.fit_in, horizontal_flip=flip_horizontally, vertical_flip=flip_vertically, width=self.target_width, height=self.target_height, halign=self.halign, valign=self.valign, focal_points=self.focal_points, smart=True, extension="JPEG", filters=[], quality=80, image="some.jpeg" ) ctx.request.engine = self.engine ctx.request.engine.extension = ".jpeg" return ctx