Configure image formats ======================= To show images on your website you should define different image formats for optimized output. Image formats can be defined in: - `config/image-formats.xml` Or when you use the SuluThemeBundle you can define the formats in your theme folder: - `path/to//config/image-formats.xml` The following example shows you different ways to define image formats: .. code-block:: xml Defining meta title ------------------- You should define a meta title for every image format, since these titles are shown to the content manager in the administration interface when cropping the images. .. code-block:: xml Author Avatar Autor Avatar Header Header Image Compression ----------------- Global image compression ^^^^^^^^^^^^^^^^^^^^^^^^ Images will not get compressed by default when you upload them. You can set the compression for images globally e.g. in the `config/packages/sulu_media.yml`. This file does not exist by default and must be created on your own. .. code-block:: yaml sulu_media: format_manager: default_imagine_options: jpeg_quality: 80 webp_quality: 80 png_compression_level: 6 Its recommended to have `jpeg_quality` between 70-90 as this is the best compromise between quality and image size. Specific image compression ^^^^^^^^^^^^^^^^^^^^^^^^^^ A image compression can also be set on a specific image format the following way: .. code-block:: xml Transformations --------------- There are several transformations available in sulu to add some effects to your images: Blur ^^^^ Will blur the image by a given `sigma` parameter: .. code-block:: xml blur 6 Grayscale ^^^^^^^^^ Will convert the image into a black/white image: .. code-block:: xml grayscale Gamma ^^^^^ Will add a gamma effect by a given `correction` parameter: .. code-block:: xml gamma 0.7 Sharpen ^^^^^^^ Will add a sharpen effect: .. code-block:: xml sharpen Paste ^^^^^ The paste transformation effect will add another image on top on the rendered image. This can be used to add a border or a copyright to the image. .. code-block:: xml paste @AppBundle/Resources/public/border.png The given image can be positioned by adding `x`, `y`, `w` `h` parameter: .. code-block:: xml paste @AppBundle/Resources/public/border.png 0 0 300 300 Combining Transformations ^^^^^^^^^^^^^^^^^^^^^^^^^ Transformation effect can also be combined the following way: .. code-block:: xml blur 6 grayscale Editing exist image formats --------------------------- If you edit exist image formats you need to run the following command to purge the image format cache: .. code-block:: bash php bin/websiteconsole sulu:media:format:cache:clear This will delete all generated images. The new image will be generated on first request of the image format. Remove old images ----------------- In a multi server setup the image formats are only removed on one server. To remove generated images which media not longer exist in the database run the following command: .. code-block:: bash php bin/websiteconsole sulu:media:format:cache:cleanup