Open fabiocaccamo opened 8 years ago
Here some smart-crop services: http://cloudinary.com/blog/smart_automatic_image_cropping_maybe_you_can_always_get_what_you_want http://thumbor.org/
Any feedback about this issue? It would be appreciated...
Hey @fabiocaccamo !
Thanks for passing along these links, I'm a bit slammed this week but I'll try to carve out some time soon to do some investigation. Do you envision smart crop being an additional 'sizer' in addition to the existing crop sizer that uses PPOI to crop {{ instance.image.smart_crop.200x200 }}
? Or a boolean setting (i.e. SMART_CROP = True
) that the existing crop sizer would use if an image's PPOI was set to the default of 0.5x0.5?
Hi @respondcreate, exactly, I imagine an additional sizer that uses a PPOI (determined by an algorithm) to crop.
Thanks for the quick feedback :).
Hey @fabiocaccamo –
That simplifies things greatly! OK, I'll carve out some time soon to investigate what it would take the implement this! :)
@respondcreate thanks!
Maybe I'm oversimplifying here, but wouldn't it be possible to create a much better crop by combining original image dimensions, the crop function and your thumbnail function?
For example: original image is 2560x1440 We want a 200x150
First, figure out the dimension constraining our crop: width_multiplier = 2560/200 # 12.8 height_multiplier = 1440/150 # 9.6 constraining_factor = min(width_multiplier, height_multiplier) constraining_factor = 9.6
Since height_multiplier is relatively smaller, 9.6 is the constraining factor.
So now we take the constraining factor and find the max size of a crop with the ratio we want:
temp_crop_height = desired_height (200) constraining_factor (9.6) # 1920 temp_crop_width = desired_width (150) constraining_factor (9.6) # 1440
Now we just take a crop of that: temp_image = original_image.crop.1920x1440
And get a thumbnail of that image desired_image =temp_image.thumbnail.200x150
Effectively we take a thumbnail of a crop. I think this would give really good results. Do you think you could do it? Would it work?
This isn't as good as the smart crop stuff, but it would be a really nice compromise.
Weaknesses I see: It takes more image processing. We probably want the original crop to use 100% image quality . . . otherwise we might cause image quality loss. (This isn't my area of expertise, so I'm just guessing)
@drigan this issue is not about cropping geometry, but cropping smartly using as center the "image gravity point" (it is different for each image), please check the links above.
Maybe I misunderstood how you intend to use the PPOI, but I was assuming that you would continue to use the PPOI when you did crop for the temp_image. This would result in an image that captures as much of the original image as possible, but doesn't waste bandwidth/loading time.
If you check the links below it's pretty clear. The PPOI should be detected automatically by the library based on the image, so it will be different for each image.
The objective is to crop images based on "automatically detected PPOI" to provide better thumbnails.
Got it, my apologies, I guess I'm requesting a new feature. Something like crop_thumbnail? I'll start a new thread for that.
Hey @drigan !
Is what you're looking to do is crop an image (leaving and then size it down to a specific size? If so, that's exactly what the current crop sizer does, from the docs:
The crop Sizer will first scale an image down to its longest side and then crop/trim inwards, centered on the Primary Point of Interest (PPOI, for short).
@respondcreate Yes it is! But when I use the crop Sizer it's not performing that way: it's cutting parts off the image that should remain. For instance: I take the 2560x1440 image from here:https://pxhere.com/en/photo/1107871 And make a crop of it with .crop.1200x200 it cuts off at the whale shark's pelvic fin rather than continuing to the edge. (It does the same at 1200x400, but interestingly behaves as expected at 1200x500) I thought the cropper was simply finding a natural 1200x200 section centered at the PPOI and using that . . . but now that I'm looking closer at it, I don't know what it's doing.
Hey @drigan !
Is there any chance you could share some of the images that you referenced above that were created from the whale shark image (the 1200x200 crop, 1200x400 crop and 1200x500 crop) that showcases how the sizer's behavior differs from your expectations? It's hard to know exactly what's happening and whether or not that's the expected behavior of the sizer or if it's a bug.
@drigan invalid image link
@fabiocaccamo you might need to log in first. It's a free site, so don't be afraid to create an account.
@respondcreate There must have been something strange going on my end: I had changed the image to something else. (The site is a test site, and is changing frequently.) After putting the image back to the whale shark image, it acts exactly the way that I would expect it to for all three of those image sizes. I have no idea what changed. :( I'm sorry!
@drigan try to click your link...
@fabiocaccamo Weird. I see what you mean. Fixed it.
It would be very nice to have smart-crop support for thumbnail generation.
There is already a python lib to do that: smartcrop.py (based on smartcrop.js).