public function xhrFormatAction(Image $image, $formatName, Request $request)
    {
        // retrieve format value object
        if (!$format = $this->container->get('synapse.image_format.loader')
            ->retrieveOne(array('name' => $formatName))
        ) {
            return new JsonResponse(
                array(
                    'error' => 400,
                    'error_message' => sprintf('No format found with name "%s".', $formatName),
                ),
                400
            );
        }

        // form handle
        $form = $this->container->get('form.factory')->createNamed(
            '',
            FormatType::class,
            $image,
            array(
                'format' => $format,
                'method' => 'POST',
                'csrf_protection' => false,
            )
        );
        $form->handleRequest($request);
        if (!$form->isValid()) {
            return new JsonResponse(
                array(
                    'error' => 400,
                    'error_message' => 'Invalid format data.',
                ),
                400
            );
        }

        // formatted image data
        return new JsonResponse(
            $form->getData()
                ->getFormattedImage($formatName)
                ->normalize(),
            201
        );
    }