Overlay an image over detected faces
Overlay an image over detected faces
Filters and effects
Presentation
Cropping
Beginner

Overlay another image of your choice on top of the faces which are automatically detected in your image. This is done by setting the overlay parameter (l in URLs) to the overlay image's public ID while setting the gravity parameter to faces (g_faces in URLs).

Cloudinary automatically detects and searches for faces within an image. There are various Cloudinary tools that you can use with the detected faces' coordinates, such as Faces-based cropping, Faces-based blurring and pixelating and more.

Here's an example of an image automatically fetched from Wikimedia Commons : Original

Here's an example of taking an image with the badge public ID, resizing it to 30 pixels-wide and overlaying it on top of all detected faces in the image: Fixed badges size

Instead of specifying a fixed value for the badge image's width, you can tell Cloudinary to resize the badge's width relative to the main image. This is done by setting the width parameter to a decimal value defining the size and setting the flags parameter to relative (fl_relative in URLs). For example, positioning multiple badges while resizing them to 10% of the width of the containing image: Faces overlay

Cloudinary can even take this one step further with the option of automatically positioning the badges and resizing them to cover 100% of the width & height of each detected face. This is done by setting the flags parameter to region_relative, fl_region_relative in URLs). By doing so, all overlays will be stretched to cover the whole face: Cover 100% of all faces

This powerful feature can be used to create some funny effects: Funny overlay