private function buildResponseFromImage(
        Request $request,
        ImageInterface $image
    ) {
        $response = new Response();
        $height = $request->get('height');
        $width = $request->get('width');
        $type = $request->get('type');
        $response
            ->setEtag($this
                ->imageEtagTransformer
                ->transform(
                    $image,
                    $height,
                    $width,
                    $type
                )
            )
            ->setLastModified($image->getUpdatedAt())
            ->setPublic();

        /**
         * If the object has not been modified, we return the response.
         * Symfony will automatically put a 304 status in the response
         * in that case.
         */
        if ($response->isNotModified($request)) {
            return $response->setStatusCode(304);
        }

        $image = $this
            ->imageManager
            ->resize(
                $image,
                $height,
                $width,
                $type
            );

        $imageData = $image->getContent();

        $response
            ->setStatusCode(200)
            ->setMaxAge($this->maxAge)
            ->setSharedMaxAge($this->sharedMaxAge)
            ->setContent($imageData);

        $response
            ->headers
            ->add([
                'Content-Type' => $image->getContentType(),
            ]);

        return $response;
    }