I’m trying to compose an image URL to both crop and scale with automatic gravity, i.e. focal point.
I know the motif of the original 1600x800 image fits within 800x800 pixels, but I don’t know where the center of the motif is.
I therefore want to apply automatic gravity, to have Cloudflare determine an appropriate focal point around which to crop the image.
Once the image is cropped, I want to display it with a size of 400x400 pixels.
This hopefully illustrates what I’m trying to achieve:
However, I cannot seem to combine this into a single URL.
I tried doing something like the following, which indeed does crop and scale, but it always crops from the left, regardless of gravity
parameter:
https://mysite.uri/cdn-cgi/image/fit=crop,gravity=auto,trim.width=800,trim.height=800,width=400/image.jpg
I can successfully crop with automatic gravity. For example, this produces an 800x800 square image, automatically cropped towards the main motif of the image:
https://mysite.uri/cdn-cgi/image/fit=crop,gravity=auto,width=800,height=800/image.jpg
However, I want to render this image as 400x400 pixels, without cropping any more of the original image.