Transform the image.

@param ServerRequestInterface $request
@param ResponseInterface      $response
@param string                 $transform

@return ResponseInterface
515075
private function transform(ServerRequestInterface $request, ResponseInterface $response, $transform)
    {
        $image = Image::fromString((string) $response->getBody());
        $hints = $this->getClientHints($request);

        if ($hints) {
            $image->setClientHints($hints);
            $response = $response->withHeader('Vary', implode(', ', $hints));
        }

        $image->transform($transform);

        $body = self::createStream($response->getBody());
        $body->write($image->getString());

        return $response
            ->withBody($body)
            ->withHeader('Content-Type', $image->getMimeType());
    }
1290327
public function recreateForNewResponseTransformer(ResponseTransformerInterface $responseTransformer): self
    {
        return new self($this->client, $responseTransformer, $this->apiExceptionTransformer, $this->accessToken);
    }
1020319
private function transformResponse($response = null)
    {
        if (is_null($response)) {
            return;
        }

        if ($body = $response->getContent()) {
            $body = Stream::create($body);
        } else {
            $body = null;
        }

        $transformed = new Response(
            $response->getStatusCode(),
            null,
            $response->getHeaders(),
            $body,
            $response->getProtocolVersion()
        );

        return $transformed;
    }
29845
public function transformResponse(ResponseInterface $response, RequestInterface $request, CommandInterface $command)
    {
        $responseClass = $this->getResponseClass($command->getName());

        if (null === $responseClass) {
            return $response;
        }

        $body = $response->getBody()->getContents();

        if (empty($body)) {
            return null;
        }

        return $responseClass === 'array' ? json_decode($body, true) : $this
            ->serializer
            ->deserialize($body, $responseClass, 'json');
    }
1224517
public function transformResponse(Response $responseIn, Response $responseOut)
    {
        $responseOut->setContent(
            json_encode($this->transformer->transform($responseIn->getContent(), $this->mapping))
        );
    }
917681
public function transform(ApiRequest $request, ApiResponse $response, array $context = []): ApiResponse
	{
		if (isset($context['exception'])) {
			return $this->transformException($context['exception'], $request, $response);
		}

		return $this->transformResponse($request, $response);
	}
330094
public function delete( ServerRequestInterface $request, ResponseInterface $response )
	{
		return $this->client->delete( $request, $response );
	}
152527
public function updateAction(ServerRequest $request, Response $response)
    {
        $script         = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extParams']['tw_componentlibrary']['script'];
        $descriptorspec = array(
            0 => array('pipe', 'r'),
            1 => array('pipe', 'w'),
            2 => array('pipe', 'a')
        );

        $process = proc_open($script, $descriptorspec, $pipes);
        stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        $status = proc_get_status($process);

        // If an error occured
        if ($status['exitcode']) {
            return $response->withStatus(500);
        }

        return $response;
    }
417646
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        if (stripos($response->getHeaderLine('Content-Type'), $this->mimetype) === 0) {
            $stream = $this->createStream($this->minify((string) $response->getBody()));

            return $response->withBody($stream)
                ->withoutHeader('Content-Length');
        }

        return $response;
    }
1068465
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $body = $request->getParsedBody();

        $method = strtoupper($body[self::METHOD_INPUT_KEY] ?? $request->getMethod());

        $request = $request->withMethod($method);

        $this->match = $this->adapter->match($request);

        return $this->match->handle($request);
    }
61194
public function executeMiddlewares(
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $requestHandler = null,
        callable $next = null
    ) : ResponseInterface {
        return $this->getRequestMiddlewares()->__invoke($request, $response, $requestHandler, $next);
    }
231414
public static function transform($object, $request)
	{
		$transformer = static::getTransformer($object);
		if (!$transformer) {
			return $object;
		}
		
		return $transformer->transform($object, $request);
	}
228164
public function handle(
        ServerRequestInterface $request, ResponseInterface $response
    )
    {
        $key = ControllerInterface::REQUEST_ATTR_VIEW_DATA;
        $vars = $request->getAttribute($key, []);
        $session = Application::container()->get('session');
        $vars['flashMessages'] = new FlashMessages();
        $request = $request
            ->withAttribute('session', $session)
            ->withAttribute($key, $vars)
        ;

        return $this->executeNext($request, $response);
    }
486450
public function applyTransformation(TransformationInterface $transform)
    {
        // array_values for re-indexing
        $this->tokens = array_values(
            array_filter(
                array_map(
                    array($transform, 'transform'),
                    $this->tokens
                ),
                function ($token) {
                    return $token!==null;
                }
            )
        );
    }
732102
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $stack = new Stack(
            $this->handlers,
            $this->handlerResolver
        );
        return $stack->handle($request);
    }
1159471
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        $code = $response->getStatusCode();
        $allowedCodes = array_keys($this->renderer) + array_keys($this->defaultErrors);
        if (in_array($code, $allowedCodes)) {
            if (!$response->getBody()->getSize()) {
                $format = FormatNegotiator::getPreferredFormat($request);

                if (isset($this->renderer[$code])) {
                    $content = $this->renderer[$code]($format);
                } else {
                    $content = $this->defaultRenderer($code, $format);
                }

                if (is_array($content)) {
                    $content = json_encode($content);
                }

                $body = $this->streamFactory->createStream($content);

                $response = $response->withBody($body);
                $response = $response->withStatus($code);

                if ($format === 'json') {
                    $response = $response->withHeader('content-type', 'application/json');
                } else {
                    $response = $response->withHeader('content-type', 'text/html; charset=utf-8');
                }
            }
        }

        return $response;
    }
733158
public function transformImage ($asset = null, $transforms = null, $defaultOptions = [])
    {
        return Imgix::$plugin->imgixService->transformImage($asset, $transforms, $defaultOptions);
    }