SymfonyWorld Online 2020
100% online
30+ talks + workshops
Live + Replay watch talks later

General Filters

2.x version
Maintained

General Filters

Background

The built-in background filter performs layer transformations (which includes creating and mergin layer operations). This filter exposes a number of background options which may be used to configure its behavior.

Example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# app/config/config.yml

liip_imagine:
    filter_sets:

        # name our filter set "my_background_filter"
        my_background_filter:
            filters:

                # use and setup the "background" filter
                background:

                    # set the background color to #00ffff
                    color: '#00ffff'

                    # set a size different from the input image
                    size: [1026, 684]

                    # center input image on the newly created background
                    position: center

Note

The background color is only visible through transparent image sections (if any), unless a size option is provided, in which case a new image is created and the input image is placed on top according to the position option.

Background Options

color: string
Sets the background color HEX value. The default color is white (#fff).
size: int[]
Sets the generated background size as an integer array containing the dimensions as width and height values.
position: string
Sets the position of the input image on the newly created background image. Valid values: topleft, top, topright, left, center, right, bottomleft, bottom, and bottomright.
transparency: integer
Sets the background alpha value. The value should be within a range of 0 - 100.

Grayscale

The built-in grayscale filter performs color transformations (which includes gray value calculations). This filter does not expose any options which may be used to configure its behavior.

Example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# app/config/config.yml

liip_imagine:
    filter_sets:

        # name our filter set "my_grayscale_filter"
        my_grayscale_filter:
            filters:

                # use and setup the "grayscale" filter
                grayscale: ~

Interlace

The built-in interlace filter performs file transformations (which includes modifying the encoding method). This filter exposes a number of interlace options which may be used to configure its behavior.

Example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# app/config/config.yml

liip_imagine:
    filter_sets:

        # name our filter set "my_interlace_filter"
        my_interlace_filter:
            filters:

                # use and setup the "interlace" filter
                interlace:

                    # set the interlace mode to line
                    mode: line

Interlace Options

mode: string
Sets the interlace mode to encode the file with. Valid values: none, line, plane, and partition.

Strip

The built-in strip filter performs file transformations (which includes metadata removal). This filter does not exposes any options which may be used to configure its behavior.

Example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# app/config/config.yml

liip_imagine:
    filter_sets:

        # name our filter set "my_strip_filter"
        my_strip_filter:
            filters:

                # use and setup the "strip" filter
                strip: ~

Watermark

The built-in watermark_image filter adds a watermark to an existing image (which includes creating and merging image operations). This filter exposes a number of watermark options which may be used to configure its behavior.

Example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# app/config/config.yml

liip_imagine:
    filter_sets:

        # name our filter set "my_watermark_filter"
        my_watermark_filter:
            filters:

                # use and setup the "watermark_image" filter
                watermark_image:

                    # path to the watermark file (prepended with "%kernel.project_dir%")
                    image: assets/watermark.png

                    # size of the water mark relative to the input image
                    size: 0.5

                    # set the position of the watermark
                    position: center

Watermark Options

image: string
Sets the location of the watermark image. The value of this option is prepended with the resolved value of the %kernel.project_dir% parameter.
size: float
Sets the size of the watermark as a relative ration, relative to the original input image.
position: string
Sets the position of the watermark on the input image. Valid values: topleft, top, topright, left, center, right, bottomleft, bottom, and bottomright.

Caution

The position option and ordering for this filter is significant. For example, calling a crop after this filter could unintentionally remove the watermark entirely from the final image.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.