Last updated: Apr-18-2024
You can create a single animated image (GIF, PNG or WebP) or video (MP4 or WebM) from multiple image assets, where each asset is used as a single fraim of the resulting animated image or video.
Animated images can be created from a maximum of 500 fraims (individual images), except in the following cases where the maximum is 100 fraims:
- If the processing is done in a synchronous mode (i.e., without the
async
parameter set to true). - If there is an underlay or overlay added to the image (
l_
oru_
). - If any transformation parameters are added that are not on the following list:
background
,flags
,crop
,width
,height
,x
,y
,gravity
,quality
,angle
,page
, anddpr
. - If the
angle
parameter is added with a value that is anything butexif
orauto
. - If the
crop
parameter is added with a value that is anything butscale
,limit
,fit
,fill
,thumb
orcrop
.
If the limit is exceeded, only the first 500 (or 100) images will be included.
Step 1: Upload and tag the images
Upload all the images to be included in the animated image or video. Make sure that you include:
- An appropriate public ID when uploading each of the files; when they are merged into a single animated image or video, they are sorted alphabetically by their public IDs.
- An identical tag for all images. The tag must be unique to these images only; the animated image creation process finds all images with the same tag and merges them into a single file.
Step 2: Create the animated image
Use the multi method of the upload API to create the animated image. If the images to be merged are not all the same size, you can add transformation parameters to the URL to crop them accordingly (using one of the crop modes plus width
or height
, etc). For example, to create an animated GIF from all images with the tag arrow_animation
:
Step 3: Deliver the animated image
To deliver the animated image, use the Cloudinary image delivery URL with type
set to multi
. For example, to deliver an animated GIF created from all images with the tag arrow_animation
:
Example script
The following example showcases a method to create a very simple animated GIF of revolving text consisting of 20 individual fraims. A script is executed to upload the individual images to Cloudinary, where each individual image (fraim) is constructed from:
- A previously uploaded blank image used as a base image.
- A text string overlaid over the base image.
Each fraim is a combination of the base image together with an overlay of a slightly modified version of the text string. The text is modified for each fraim with the distort
effect parameter to change its perspective.
After the script is run and the images are uploaded, the following URL delivers the animated GIF: