abstract class Flag implements CommonFlagInterface, LayerFlagInterface, ImageFlagInterface, VideoFlagInterface

Defines flags that you can use to alter the default transformation behavior.

Learn more: Image transformation flags | Video transformation flags

Methods

attachment(string $filename = null)

Delivers the image as an attachment.

ignoreAspectRatio()

Allows specifying only either width or height so the value of the second axis remains as is, and is not recalculated to maintain the aspect ratio of the original image.

forceIcc()

Adds ICC color space metadata to the image, even when the original image doesn't contain any ICC data.

forceStrip()

Instructs Cloudinary to clear all image meta-data (IPTC, Exif and XMP) while applying an incoming transformation.

getInfo()

Returns metadata of the input asset and of the transformed output asset in JSON instead of the transformed image.

immutableCache()

Sets the cache-control to immutable for the asset, which tells the browser that the asset does not have to be revalidated with the server when the page is refreshed, and can be loaded directly from the cache.

keepAttribution()

Keeps the copyright related fields when stripping meta-data. Without this flag, Cloudinary's default behavior is to strip all meta-data when generating new image transformations.

keepIptc()

Keeps all meta-data. Without this flag, Cloudinary's default behavior is to strip all meta-data when generating new image transformations.

generic(string $name, mixed ...$args)

Sets generic flag specified by name.

animated()

Used when delivering a video file as an image format that supports animation, such as animated WebP.

anyFormat()

When used together with automatic quality (q_auto): allow switching to PNG8 encoding if the quality algorithm decides that it's more efficient.

animatedPng()

When converting animated images to PNG format, generates an animated PNG from all the frames in the original animated file instead of only from the first still frame.

animatedWebP()

When converting animated images to WebP format, generate an animated WebP from all the frames in the original animated file instead of only from the first still frame.

clip()

Trims pixels according to a clipping path included in the original image (e.g., manually created using PhotoShop).

clipEvenOdd()

Trims pixels according to a clipping path included in the original image (e.g., manually created using PhotoShop) using an evenodd clipping rule.

lossy()

Automatically use lossy compression when delivering animated GIF files.

preserveTransparency()

When used with automatic fetch_format (f_auto): ensures that images with a transparency channel will be delivered in PNG format.

png8()

Generate PNG images in the PNG8 format.

png24()

Generates PNG images in the PNG24 format.

png32()

Generates PNG images in the PNG32 format.

progressive(string $mode = null)

Generates a JPG image using the progressive (interlaced) JPG format.

rasterize()

Reduces the image to one flat pixelated layer (as opposed to the default vector based graphic) in order to enable PDF resizing and overlay manipulations.

sanitize()

Instructs Cloudinary to run a sanitizer on the image (relevant only for the SVG format).

stripProfile()

Instructs Cloudinary to clear all ICC color profile data included with the image.

tiff8Lzw()

Generates TIFF images using LZW compression and in the TIFF8 format.

ignoreMaskChannels()

A qualifier that ensures that an alpha channel is not applied to a TIFF image if it is a mask channel.

regionRelative()

Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the overlaid region. Currently regions are only defined when using gravity 'face', 'faces' or 'custom'.

relative()

Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the containing image instead of the added layer.

cutter()

Trims pixels according to the transparency levels of a given overlay image.

layerApply()

Applies all chained transformations, until a transformation component that includes this flag, on the last added overlay or underlay instead of applying on the containing image.

replaceImage()

Replaces the first image embedded in a PDF with the image stipulated as an overlay, instead of adding it as another overlay.

splice()

Splices the video stipulated as an overlay on to the end of the container video instead of adding it as an overlay.

noOverflow()

Prevents Cloudinary from extending the image canvas beyond the original dimensions when overlaying text and other images.

textNoTrim()

By default, text overlays are trimmed tightly to the text with no excess padding. This flag adds a small amount of padding around the text overlay string.

textDisallowOverflow()

Returns an error if the text overlay exceeds the image boundaries.

tiled()

Tiles the added overlay over the entire image.

streamingAttachment(string $filename = null)

If the requested video transformation has already been generated, this flag works identically to Flag::attachment.

hlsv3()

Deliver an HLS adaptive bitrate streaming file as HLS v3 instead of the default version (HLS v4).

keepDar()

Keep the Display Aspect Ratio metadata of the uploaded video (if it’s different from the current video dimensions).

noStream()

Don't stream a video that is currently being generated on the fly. Wait until the video is fully generated.

mono()

Convert the audio channel to mono

truncateTS()

Truncate (trim) a video file based on the start time defined in the metadata (relevant only where the metadata includes a directive to play only a section of the video).

waveform()

Create a waveform image (in the format specified by the file extension) from the audio or video file.

Details

static FlagQualifier attachment(string $filename = null)

Delivers the image as an attachment.

When the image's URL is accessed, tells the browser to save the image instead of embedding it in a page. You can optionally set the attachment's filename. If you don't specify a filename, then the original image’s filename will be used as the attachment filename (rather than the public_id) unless the discard_original_filename qualifier was set during the file upload.

Parameters

Name Type Description
$filename string The attachment's filename

Return Value

FlagQualifier

static FlagQualifier ignoreAspectRatio()

Allows specifying only either width or height so the value of the second axis remains as is, and is not recalculated to maintain the aspect ratio of the original image.

Return Value

FlagQualifier

static FlagQualifier forceIcc()

Adds ICC color space metadata to the image, even when the original image doesn't contain any ICC data.

Return Value

FlagQualifier

static FlagQualifier forceStrip()

Instructs Cloudinary to clear all image meta-data (IPTC, Exif and XMP) while applying an incoming transformation.

Return Value

FlagQualifier

static FlagQualifier getInfo()

Returns metadata of the input asset and of the transformed output asset in JSON instead of the transformed image.

When used with g_auto, the metadata includes the proposed g_auto cropping coordinates.

Return Value

FlagQualifier

static FlagQualifier immutableCache()

Sets the cache-control to immutable for the asset, which tells the browser that the asset does not have to be revalidated with the server when the page is refreshed, and can be loaded directly from the cache.

Currently supported only by Firefox.

Return Value

FlagQualifier

static FlagQualifier keepAttribution()

Keeps the copyright related fields when stripping meta-data. Without this flag, Cloudinary's default behavior is to strip all meta-data when generating new image transformations.

Return Value

FlagQualifier

static FlagQualifier keepIptc()

Keeps all meta-data. Without this flag, Cloudinary's default behavior is to strip all meta-data when generating new image transformations.

Note that this flag cannot be used in conjunction with the automatic quality transformation (q_auto).

Return Value

FlagQualifier

static FlagQualifier generic(string $name, mixed ...$args)

Sets generic flag specified by name.

Parameters

Name Type Description
$name string The flag name.
...$args mixed The flag value.

Return Value

FlagQualifier

static FlagQualifier animated()

Used when delivering a video file as an image format that supports animation, such as animated WebP.

Plays all frames rather than just delivering the first one as a static image. Use this flag in addition to the flag or qualifier controlling the delivery format, for example f_auto or fl_awebp.

Note: When delivering a video in GIF format, it is delivered as an animated GIF by default and this flag is not necessary. To deliver a single frame of a video in GIF format, use the page qualifier.

Return Value

FlagQualifier

static FlagQualifier anyFormat()

When used together with automatic quality (q_auto): allow switching to PNG8 encoding if the quality algorithm decides that it's more efficient.

Return Value

FlagQualifier

static FlagQualifier animatedPng()

When converting animated images to PNG format, generates an animated PNG from all the frames in the original animated file instead of only from the first still frame.

Note that animated PNGs are not supported in all browsers and versions.

Return Value

FlagQualifier

static FlagQualifier animatedWebP()

When converting animated images to WebP format, generate an animated WebP from all the frames in the original animated file instead of only from the first still frame.

Note that animated WebPs are not supported in all browsers and versions.

Return Value

FlagQualifier

static FlagQualifier clip()

Trims pixels according to a clipping path included in the original image (e.g., manually created using PhotoShop).

Return Value

FlagQualifier

static FlagQualifier clipEvenOdd()

Trims pixels according to a clipping path included in the original image (e.g., manually created using PhotoShop) using an evenodd clipping rule.

Return Value

FlagQualifier

static FlagQualifier lossy()

Automatically use lossy compression when delivering animated GIF files.

This flag can also be used as a conditional flag for delivering PNG files: it tells Cloudinary to deliver the image in PNG format (as requested) unless there is no transparency channel - in which case deliver in JPEG format.

Return Value

FlagQualifier

static FlagQualifier preserveTransparency()

When used with automatic fetch_format (f_auto): ensures that images with a transparency channel will be delivered in PNG format.

Return Value

FlagQualifier

static FlagQualifier png8()

Generate PNG images in the PNG8 format.

Return Value

FlagQualifier

static FlagQualifier png24()

Generates PNG images in the PNG24 format.

Return Value

FlagQualifier

static FlagQualifier png32()

Generates PNG images in the PNG32 format.

Return Value

FlagQualifier

static FlagQualifier progressive(string $mode = null)

Generates a JPG image using the progressive (interlaced) JPG format.

This format allows the browser to quickly show a low-quality rendering of the image until the full-quality image is loaded.

Parameters

Name Type Description
$mode string The mode to determine a specific progressive outcome as follows: * semi - A smart optimization of the decoding time, compression level and progressive rendering (less iterations). This is the default mode when using q_auto. * steep - Delivers a preview very quickly, and in a single later phase improves the image to the required resolution. * none - Use this to deliver a non-progressive image. This is the default mode when setting a specific value for quality.

Return Value

FlagQualifier

See also

Progressive

static FlagQualifier rasterize()

Reduces the image to one flat pixelated layer (as opposed to the default vector based graphic) in order to enable PDF resizing and overlay manipulations.

Return Value

FlagQualifier

static FlagQualifier sanitize()

Instructs Cloudinary to run a sanitizer on the image (relevant only for the SVG format).

Return Value

FlagQualifier

static FlagQualifier stripProfile()

Instructs Cloudinary to clear all ICC color profile data included with the image.

Return Value

FlagQualifier

static FlagQualifier tiff8Lzw()

Generates TIFF images using LZW compression and in the TIFF8 format.

Return Value

FlagQualifier

static FlagQualifier ignoreMaskChannels()

A qualifier that ensures that an alpha channel is not applied to a TIFF image if it is a mask channel.

static FlagQualifier regionRelative()

Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the overlaid region. Currently regions are only defined when using gravity 'face', 'faces' or 'custom'.

Return Value

FlagQualifier

static FlagQualifier relative()

Modifies percentage-based width & height qualifiers of overlays and underlays (e.g., 1.0) to be relative to the containing image instead of the added layer.

Return Value

FlagQualifier

static FlagQualifier cutter()

Trims pixels according to the transparency levels of a given overlay image.

Wherever the overlay image is transparent, the original is shown, and wherever the overlay is opaque, the resulting image is transparent.

Return Value

FlagQualifier

static FlagQualifier layerApply()

Applies all chained transformations, until a transformation component that includes this flag, on the last added overlay or underlay instead of applying on the containing image.

Return Value

FlagQualifier

static FlagQualifier replaceImage()

Replaces the first image embedded in a PDF with the image stipulated as an overlay, instead of adding it as another overlay.

Return Value

FlagQualifier

static FlagQualifier splice()

Splices the video stipulated as an overlay on to the end of the container video instead of adding it as an overlay.

Return Value

FlagQualifier

static FlagQualifier noOverflow()

Prevents Cloudinary from extending the image canvas beyond the original dimensions when overlaying text and other images.

Return Value

FlagQualifier

static FlagQualifier textNoTrim()

By default, text overlays are trimmed tightly to the text with no excess padding. This flag adds a small amount of padding around the text overlay string.

Return Value

FlagQualifier

static FlagQualifier textDisallowOverflow()

Returns an error if the text overlay exceeds the image boundaries.

Return Value

FlagQualifier

static FlagQualifier tiled()

Tiles the added overlay over the entire image.

Return Value

FlagQualifier

static FlagQualifier streamingAttachment(string $filename = null)

If the requested video transformation has already been generated, this flag works identically to Flag::attachment.

However, if the video transformation is being requested for the first time, this flag causes the video download to begin immediately, streaming it as a fragmented video file.

In contrast, if the regular fl_attachment flag is used when a user requests a new video transformation, the download will begin only after the complete transformed video has been generated.

Most standard video players successfully play fragmented video files without issue.

Parameters

Name Type Description
$filename string The attachment's filename

Return Value

FlagQualifier

See also

Flag::attachment

static FlagQualifier hlsv3()

Deliver an HLS adaptive bitrate streaming file as HLS v3 instead of the default version (HLS v4).

Delivering in this format requires a private CDN configuration.

static FlagQualifier keepDar()

Keep the Display Aspect Ratio metadata of the uploaded video (if it’s different from the current video dimensions).

Return Value

FlagQualifier

static FlagQualifier noStream()

Don't stream a video that is currently being generated on the fly. Wait until the video is fully generated.

Return Value

FlagQualifier

static FlagQualifier mono()

Convert the audio channel to mono

Return Value

FlagQualifier

static FlagQualifier truncateTS()

Truncate (trim) a video file based on the start time defined in the metadata (relevant only where the metadata includes a directive to play only a section of the video).

Return Value

FlagQualifier

static FlagQualifier waveform()

Create a waveform image (in the format specified by the file extension) from the audio or video file.

Return Value

FlagQualifier