Trimming images via URL

Hello,

we’d like to ask for support regarding on-demand image trimming.

For the last 2 months we were serving trimmed images using such a URL pattern:
https://imagedelivery.net/cdn-cgi/image/trim=10;10;20;20/QJK89lvTX7ncD07wQAcNLQ/b8521efa-e312-4b4c-4536-a5392d8de300

However, this stopped working on April 13th. The link above redirects to https://imagedelivery.net/QJK89lvTX7ncD07wQAcNLQ/b8521efa-e312-4b4c-4536-a5392d8de300 which says “malformed URL”.

In the console, just before the redirect, we can see another error in the browser’s console (see the attached screenshot).

Why did it stop working? How to make it work?

As an alternative we’ve tried serving the URL as described in https://developers.cloudflare.com/images/image-resizing/url-format/. We have a site “contribute.to” on Cloudflare and we’ve set up CNAME for “images” to point to http://imagedelivery.net in that site’s DNS panel in Cloudflare. Now, the following URL works and serves a trimmed image: https://images.contribute.to/cdn-cgi/image/trim=100;200;300;400/https://idsb.tmgrup.com.tr/ly/uploads/images/2021/09/20/thumbs/800x531/146113.jpg.

But it only works for images hosted somewhere else. It does not work for our own images hosted at Cloudflare.

When we try:
https://images.contribute.to/cdn-cgi/image/trim=100;100;150;200/https://imagedelivery.net/QJK89lvTX7ncD07wQAcNLQ/b8521efa-e312-4b4c-4536-a5392d8de300/original we get “Error 9524: image could not be resized (403)”

If we try https://images.contribute.to/cdn-cgi/image/trim=100;100;150;200/https://images.contribute.to/QJK89lvTX7ncD07wQAcNLQ/b8521efa-e312-4b4c-4536-a5392d8de300/original - it redirects to https://imagedelivery.net/QJK89lvTX7ncD07wQAcNLQ/b8521efa-e312-4b4c-4536-a5392d8de300/original and we see the following error: “Error 1014 Ray ID: 6fbc48994a330f5e • 2022-04-14 12:00:52 UTC CNAME Cross-User Banned You’ve requested a page on a website that is part of the Cloudflare network. The host is configured as a CNAME across accounts on Cloudflare, which is prohibited by security policy”

How should we change our setup to make it work? Is it the DNS configuration? What should it be then?

Regards

p.s: last but not least, I would like to remind you that we are on a PRO plan but despite having opened a ticket (id: 2424783) 6 days ago, we got no reply yet!

Hi, the recommended approach for Cloudflare Images is to create named variant with trim=10;10;20;20 definition. Could you try that first?

We will provide a documentation soon how to transform image uploaded to Cloudflare Images using flexible resizing parameters. I will update the thread once we have the updated documentation.

Just to clarify the used format https://imagedelivery.net/cdn-cgi/image/trim=10;10;20;20/QJK89lvTX7ncD07wQAcNLQ/b8521efa-e312-4b4c-4536-a5392d8de300 was never officially documented or supported.

1 Like

Hi @yevgen what do you mean by “named variant” ? You mean we have to create it upfront in the dashboard? If yes, we unfortunately need to resize the image dynamically

I see, I will reply in private as we are still working on public documentation.

Please use flexible variants: https://developers.cloudflare.com/images/cloudflare-images/resize-images/#flexible-variants

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.