Focal Point Cropping Activated

Smart cropping of images to highlight the image's focal point, at any size.

Finding Focus

Creating multiple sizes and aspect ratios for images used to require manually cropping and saving several renditions. This was time-consuming and challenging to manage, especially if we had to make changes to the original image. These changes often required us to re-edit and save each rendition again. Now, with dotCMS' focal point cropping, we can generate multiple versions on-demand, allowing us to bring the most compelling and relevant parts of the photo into focus at any size or dimension.

What is Focal Point Cropping

Often in photographs, the primary subject is rarely in the center of the image, making automatic cropping and resizing ineffective in most cases. With focal point cropping, we can select the focus of the image, and dotCMS will intelligently crop and scale the image around it. This means we manage a single image and let dotCMS handle all the variations we need for responsive design, social posts, articles, banners, and more.

How it Works

Let's start with a typical editorial-style photo. We'll go step by step, seeing how to zoom, crop and change ratios of the image.

Here's the original image using the basic dotCMS resize property at 1280px width without any cropping.

Filters: /resize_w/1280

As we can see, the composition has the primary subject in the right third of the image. Something very common based on the rule of thirds in photography, but we need the image to fit several sizes and aspect ratios without losing the primary subject matter. That's where the dotCMS focal point parameter (fp) comes in. It will let us set the focus on the subject of the photo, in this case, that the wooden model and crop around it.

By default, dynamically cropping an image will crop from the center, which gives us this:

Filters: /resize_w/1280/crop_w/1024/crop_h/480

The image is the right size, but cropping from the center has pushed the wooden model down. Using the focal point parameters, we'll be able to adjust this. The focal point parameter takes two values, the x, and y. These values are percentages of the image. For example, if we wanted the focal point to be right 70% and down 45%, we would pass the following parameters ( /fp/.7,.40 ), and this would be the result.

Filters: /image/resize_w/1280/crop_w/1024/crop_h/480/fp/.7,.40

Adjusting the Zoom

One excellent use case for focal-point cropping is changing the image's composition. We can do this by merely changing the sizes and aspect ratios. It allows us to control the visual interest, especially at smaller sizes.

For a smaller version, this is what we get using the same parameters as before—it works, but its starting to lose its interest.

Filters: /resize_w/640/crop_w/512/crop_h/240/fp/.7,.40

To fix this, we need to zoom in on the focal point to create a more exciting composition at a smaller size; however, there is no "zoom" filter in dotCMS. So, to achieve the same effect, we'll need to resize the image first and then call the crop and focal point filters last. This will enlarge the area we want to crop first before applying the crop filter.

Note: The order of the filters does make a difference

Filters: /resize_w/1280/crop_w/512/crop_h/240/fp/.75,.4

Aspect Ratio

Now that we have played around with zooming and centering the subject matter, let's take a look at changing the size ratio. This will come in handy when creating different versions for different channels and breakpoints. For this example, let's create three versions: one for tablets (640x320), one for phones (320x200), and one for a thumbnail listing ( 125x125). We will keep the focal point the same in all of these examples; we will only change the size and crop ratios.

Tablet
resize: 1300px
crop width: 640
crop height: 320
focal point x: 70%
focal point y: 45%

Phone
resize original: 1300px
crop width: 320
crop height: 200
focal point x: 70%
focal point y: 45%

Thumbnail resize original: 800px
crop width: 125
crop height: 125
focal point x: 70%
focal point y: 45%

Hopefully, using focal-point cropping in dotCMS will help save you time and frustration. For more tips and feature articles on dotCMS, please make sure to join our mailing list.

More Examples