News for hackers. Stuff that matters.
Re:Issues with Cloudflare Images by LukeLambert on Tuesday December 07, 2021 @12:35PM (#29475578)
Image Resizing is technically a separate product, so I apologize if this is off-topic, but it appears to be missing the most useful `fit` mode – something like `fit=cover-scale-down`. I never want to enlarge an image on the server, since I can do that client-side. If I request a version with the dimensions 512×512 (square), but the source image is only 400×600, there should be a way to get a resulting image of 400×400. Am I misreading the docs? https://developers.cloudflare.com/images/image-resizing/url-...

Edit: Changed suggested name of fit mode for clarity.

Re:Issues with Cloudflare Images by gregbrimble on Tuesday December 07, 2021 @12:58PM (#29475899)
I think "scale-down" is the closest to what you're after. If you have a 400x600 original, and request 512x512, you'll be served a 341x512 image. This maintains the original image's aspect ratio, and a fits within the requested (512x512) size.

Original: https://via.placeholder.com/400x600 Resized: https://gregbrimble.com/cdn-cgi/image/fit=scale-down,w=512,h...

Re:Issues with Cloudflare Images by LukeLambert on Tuesday December 07, 2021 @01:28PM (#29476287)
I want to maintain the aspect ratio of my crop, not that of the source image. Perhaps `fit=cover-scale-down` would be a more appropriate name. In other words, I always want a square image <= 512px wide. I think this is a very common use case.
Re:Issues with Cloudflare Images by rhizome on Tuesday December 07, 2021 @02:15PM (#29476932)
If there's no way to specify where the center (or w/e) of your crop is on the source image, it's not going to happen.
Re:Issues with Cloudflare Images by Aeolun on Tuesday December 07, 2021 @07:47PM (#29480105)
Even I can do ‘most interesting part’ detection. CF certainly can.
Re:Issues with Cloudflare Images by user-the-name on Tuesday December 07, 2021 @12:56PM (#29475873)
Isn't that fit=crop?
Re:Issues with Cloudflare Images by LukeLambert on Tuesday December 07, 2021 @01:50PM (#29476594)
fit=crop and fit=cover only work well if the source dimensions are greater than 512×512. If either dimension of the source is smaller, the behavior is useless.

fit=cover will return a square (as requested), but will enlarge it (which you never want because it wastes bandwidth).

fit=crop will cut off excess pixels if either dimension exceeds 512, but it does not always return a square. (And contrary to the docs, it does not behave like fit=scale-down.)