hey Walkah,

How would you feel about a patch that adds an "exact size" checkbox to each derivative type in admin/settings/image? I've been doing something like this for a number of sites who have specific thumbnail sizes as part of their design, and I've got a pretty good little bit of code that works for making an exact size derivative by cropping where necessary. It's 4.6, but I don't think it would be a lot of work to push this to 4.7.

Would this be appropriate as part of image.module, or would you rather this go as a separate contrib somehow?

Comments

Bèr Kessels’s picture

I would 1 this for sure.
First of all because this feature will "document" the current undocumented featuerr of somehow flexible resizing
And secondly it will allow, as you state, exact sizes. Cropping is often nice.

Montuelle’s picture

I imagine when you say "exact size" for derivatives there is also a resize so the crop is either horizontal either vertical but not both.

Then it would be good, when an new image is created, if the user could specify on which side to crop.

A very simple system would be a numeric field with values -1, 0, +1 indicating in wich direction the center should move:

  • 0 means keeps the center
  • -1 means crop on the right or on the top (according to the aspect ratio)
  • +1 means crop on the left or on the bottom (according to the aspect ratio)

But using percentage (range from -100% to +100%) would not be more complicated to allow more control on the shifting of the derivative compared to the original.

Bèr Kessels’s picture

Wh all that complexity?

It is far easier to say:
* resize untill H or W has the desired value.
* cut frm both sides of the still-too-long-value 50% off

example: setting:100x120
110x440 image > resized to 100x400 > cropped to 100x120 by cutting 140px off each left and right side
400x140 image > resized to 343x120> cropped to by cutting 121px off each bottom and top side

Montuelle’s picture

I agree with you. What you describe is the way to crop and resize to reach a given "fixed size".
As you mention the "logical" cut is to cut 50% off if still-too-long.
This algorithm is exactly the one that I had in mind in writing the first sequence of my previous post.

What I was trying to suggest (in case a fixed size is imposed by the administrator) was to add a field in /node/add/image so that any user can change that default of 50%. For a given image, the user may prefer for example to cut 0% on the left and 100% on the right.

I agree this is not a fundamental request. But photographs may just found their thumbnails a bit more aesthetic if they can choose where to cut.

Bèr Kessels’s picture

Montuelle. that is a lot of cruft and a lot of interface for such a hardcore feature.
I would suggest you add that to a contrib module. With all the hooks and the form_alter we have it should not be hard to achieve.

joshk’s picture

Berkes: I actually tended to implement the opposite: crop to correct aspect-ratio, then scale to the correct size. Six of one, half dozen of another. There may be some advantages in image quality one way or another, but I agree that keeping it simple is best.

I'm going to implement a contrib module that will enable this on image nodes and user profiles through nodeapi and hook_user. Hopefully it will demonstrate the utility of this function to everyone.

Stefan Nagtegaal’s picture

Status: Active » Fixed

There is an image_exact.modle which does exactly what you guys want it todo..

Anonymous’s picture

Status: Fixed » Closed (fixed)