The complete reference of media transformations supported by the TwicPics API.
There are two kinds of transformations: ones that actually modify the image (or video) and others that change the context of further transformations down the manipulation chain.
All transformations follow the same structure:
<name>is the name of the transformation
<parameters>is an expression specifying the parameters for the transformation
resize=400will resize the image to 400 pixels in width while conserving the source image aspect ratio
resize=640x480will resize the image to exactly 640 pixels in width per 480 pixels in height, potentially altering its aspect ratio
Transformations can be chained together using the character
/. There is no limit to the number of transformations you can chain, save for the limit in size of a URL as enforced by your browser. No matter how complex the manipulation, TwicPics will optimize it for speed and accuracy on the fly.
Transformations behave differently depending on which point in the image is the main focus. TwicPics will do its best to keep this focus point as central as possible within the transformed image.
By default, the focus point is in the middle of the image but you can change its coordinates by using the focus transformation.
When adding a transformation to the chain, the parameters given are interpreted as if previous transformations had already been performed (ie. as if the source image was the result of the previous transformations).
resize=340/resize=50pwill result in an image that is 170 pixel-wide
resize=50p/focus=20x10will put the focus point at coordinates
40x20of the source image
Since TwicPics will optimize the manipulation, be aware that a transformation may shadow what came before it. For instance
resize=50p/resize=340 will result in an image that is 340 pixel-wide: TwicPics will simply ignore the first resize.
List of transformations
Corrects the colors of the image for color blind people suffering from achromatopsia.
background specifies a color that will show through transparent and translucent parts of the image. This will have no effect on images with no transparency nor translucency.
The background color will also fill the borders created by an inside transformation. This can be superceded by using the border transformation.
If multiple background transformations are specified, they are applied in order. If a background uses an opaque color, any background thereafter will be ignored.
border specifies a color to fill borders eventually created by an inside transformation. It supercedes background in that instance and it is notably possible to ensure both a solid background and translucent borders by using
border=transparent. border will have no effect on images that have no inside applied to them.
If multiple border transformations are specified, they are applied in order. If a border uses an opaque color, any border thereafter will be ignored.
contain behaves like the CSS background size "contain". It will resize the image so that it completely fits inside the target area while conserving the original aspect ratio. The resulting image will be smaller than a target size which aspect ratio is not the same as the aspect ratio of the input.
For instance, applying
contain=150x100 to our beloved face of a cat will result in the following 150x94 image:
Syntax: contain-max=<pixel size>
A conditional version of contain that will be applied only when one of the given lengths is smaller than the corresponding input image dimension.
Syntax: contain-min=<pixel size>
A conditional version of contain that will be applied only when one of the given lengths is larger than the corresponding input image dimension.
cover behaves like the CSS background size "cover". It will resize the image so that it completely fills the target area while conserving the original aspect ratio. If some parts of the image end up outside of the covered area, they are cropped.
cover=100x100 of a 300x188 image would first scale the image down to a height of 100 pixels and then crop along the x-axis as demonstrated below:
cover will use the focus point as a guide and will crop the image so that the focus point is as central as possible in the resulting image. For instance,
focus=85x85/cover=100x100 will behave as follows:
When a ratio is provided, cover will extract the biggest possible area that satisfies the ratio and is as centered on the focus point as possible. For instance,
focus=85x85/cover=1:1 will behave as follows:
Syntax: cover-max=<pixel size>
A conditional version of cover that will be applied only when one of the given lengths is smaller than the corresponding input image dimension.
Syntax: cover-min=<pixel size>
A conditional version of cover that will be applied only when one of the given lengths is larger than the corresponding input image dimension.
crop will extract a zone from the image which size is the given crop size. If no coordinates are given, the focus point will be used as a guide to determine where to start the extraction. If coordinates are given, they will be used to determine the top-left pixel from which to start the extraction and the focus point will be reset to the center of the resulting image.
Here are two examples:
Corrects the colors of the image for color blind people suffering from deuteranopia.
flip will invert the image horizontally, vertically or both depending on the axis provided.
|horizontal and vertical|
focus will set the focus point coordinates. It doesn't modify the output image in any way but will change the behavior of further transformations that take the focus point into account (namely cover, crop and zoom).
If an anchor is provided, then the focus point will be the corresponding corner or the middle point of the corresponding border.
auto is used in place of actual coordinates, the focus point will be chosen automagically for you! Note that
auto is not implemented for videos yet.
inside behaves like the CSS background size "contain". It will resize the image so that it completely fits inside the target area. Contrary to the contain transformation, translucent borders will be added if the resulting aspect ratio is not the same as the aspect ratio of the input so that the resulting image has the exact, physical, size specified.
If the background transformation is used, then the background color will be used to fill the borders. If you wish to have a different color than the background color for the added borders, you can use the border transformation.
It is not possible to perform a crop after an inside.
Syntax: max=<pixel size>
Alias of contain-max.
Syntax: min=<pixel size>
Alias of contain-min.
- output=<preview type>
Specifies the output format. It can be an image format, a video format or a preview format. Only the last output in the manipulation expression is taken into account. By default, TwicPics will "smart-guess" the best output format for the browser currently issueing the request but you can use output to override this behavior.
Available image formats are:
aviffor AV1 Image File Format
heiffor High Efficiency Image File Format
webpdepending on the browser, useful to extract the first frame of a video)
jpegfor Joint Photographic Experts Group
pngfor Portable Network Graphics
Available video formats are:
h264for an H.264 stream in an MPEG-4 Part 14 container
h265for an H.265 stream in an MPEG-4 Part 14 container
vp9for a VP9 stream in a WebM container
Available preview types are:
blank: a blank, totally translucent version of the resulting image
maincolor: a solid color image containing the most important color in the resulting image
meancolor: a solid color image containing the mean color of the resulting image
preview: a blurry preview of the resulting image
For videos, previews are based on the first frame of the resulting video.
In addition, you can use
output=auto to ensure TwicPics' "smart-guess" of the output format is used even if an output format has already been specified by the default manipulation of your path.
Corrects the colors of the image for color blind people suffering from protanopia.
Specifies the output quality as a number between 1 and 100.
quality will be ignored when:
pngand truecolor is on
outputis a preview format
A conditional version of quality that will be applied only when given quality is below current quality.
A conditional version of quality that will be applied only when given quality is above current quality.
resize will resize the image to the specified size. If only one length is provided, the other dimension will be determined so as to respect the aspect ratio of the input image. If both lengths are provided, the aspect ratio may not be respected.
Here are three resize operations on the same source image:
If a ratio is provided, the image will be resized so that it stays as close as possible to its current surface (i.e number of pixels) while respecting the given aspect ratio as closely as possible.
focus=85x85/resize=4:3 will result in the following 274x206 image:
The 300x188 image was resized to a 274x206 image (respecting the 4:3 ratio as best as possible). The initial surface was (300x188=) 56,400 pixels. The final surface is (274x206=) 56,444 pixels.
Syntax: resize-max=<pixel size>
A conditional version of resize that will be applied only when one of the given lengths is smaller than the corresponding input image dimension.
Syntax: resize-min=<pixel size>
A conditional version of resize that will be applied only when one of the given lengths is larger than the corresponding input image dimension.
Corrects the colors of the image for color blind people suffering from protanopia.
truecolor can be used to prevent color quantization. If no boolean is provided,
true is assumed. By default, quantization is allowed (
When may quantization occur? Whenever the output format is
png. By default, TwicPics will quantize colors to reduce the size of the output image. It is possible to prevent this behaviour by setting truecolor to
Be aware that TwicPics will automatically output PNG images when:
- no output format is specified,
- the source image has an alpha channel,
- and, target browser does not support WebP.
As such, use truecolor if you want to distribute substantially larger but more accurate images with translucency to users on browsers that do not support WebP.
turn will change the orientation of the image. It accepts an angle. Angles will be rounded to the closest multiple of 90°.
Zooms into the image by a factor equal or superior to 1 towards the focus point while preserving the image size.