'This function is called after the PRE_LOAD filters have been applied.
It applies the AFTER_LOAD filters on the result, then crops the image.'

@gen.coroutine
def get_image(self):

    try:
        result = (yield self._fetch(self.context.request.image_url))
        if (not result.successful):
            if (result.loader_error == LoaderResult.ERROR_NOT_FOUND):
                self._error(404)
                return
            elif (result.loader_error == LoaderResult.ERROR_UPSTREAM):
                self._error(502)
                return
            elif (result.loader_error == LoaderResult.ERROR_TIMEOUT):
                self._error(504)
                return
            elif (hasattr(result, 'engine_error') and (result.engine_error == EngineResult.COULD_NOT_LOAD_IMAGE)):
                self._error(400)
                return
            else:
                self._error(500)
                return
    except Exception as e:
        msg = '[BaseHandler]    get_image    failed    for    url    `{url}`.    error:    `{error}`'.format(url=self.context.request.image_url, error=e)
        self.log_exception(*sys.exc_info())
        if ('cannot    identify    image    file' in e.message):
            logger.warning(msg)
            self._error(400)
        else:
            logger.error(msg)
            self._error(500)
        return
    normalized = result.normalized
    buffer = result.buffer
    engine = result.engine
    req = self.context.request
    if (engine is None):
        if (buffer is None):
            self._error(504)
            return
        engine = self.context.request.engine
        try:
            engine.load(buffer, self.context.request.extension)
        except Exception:
            self._error(504)
            return
    self.context.transformer = Transformer(self.context)
    def transform():
        self.normalize_crops(normalized, req, engine)
        if req.meta:
            self.context.transformer.engine = self.context.request.engine = JSONEngine(engine, req.image_url, req.meta_callback)
        after_transform_cb = functools.partial(self.after_transform, self.context)
        self.context.transformer.transform(after_transform_cb)
    self.filters_runner.apply_filters(thumbor.filters.PHASE_AFTER_LOAD, transform)
