In the current version (5.x-2.0), within the deprecated scale tool there is an option to select inside or outside dimensions. This is extremely useful for creating square images from non-square images. There's an indication that this feature will be removed in 2.1, and depreciated in favor of the Scale and Crop tool - however, that tool doesn't create square images from non-square images. Is there a method for creating square images in 2.1, while scaling to the outside dimensions? If not, please retain this feature from 2.0.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

erikhopp’s picture

I'd like to retain this feature in the next version of imagecache too!

drewish’s picture

Status: Active » Postponed (maintainer needs more info)

i'm not sure what you're talking about. scale and crop will most definitely create square images from non-square images... have you given it a try?

coreyp_1’s picture

I'm having the same problem.

Suppose I have an image, 100x200, that I want re-sized to at most 50x50. I don't care how wide or how tall the 50x50 actually is, as long as neither dimension exceeds 50 (and it keeps the same aspect ratio). In this case, the resulting picture should be 25x50. I don't see how to accomplish this without using the "deprecated" inside/outside options.

alexh’s picture

Inside/outside dimension feature is very much necessary to scale a mixed set of landscape/portrait images for placing them into a square border (like an slide frame). Please keep it!

Island Usurper’s picture

It sounds like you just need the new Scale action. Set both dimensions to maximum size that you want. That's equivalent to the Inside option.

I don't know how you would emulate the Outside option, but I don't think it's nearly as useful.

Just so long as there's a good upgrade path, I'll be happy.

Anonymous’s picture

+1. I'm lost without the Outside option (or a workable alternative).

starbow’s picture

+1, I use the Outside scale and the crop center to get a particular square. I don't see any way to get this particular effect from the non-deprecated actions.

droople’s picture

+1

please keep

HansBKK’s picture

+1 on preserving some sort of "outside scale" if there are good reasons for dropping the deprecated action

dopry, a UI wording suggestion (unless I've misunderstood the function?)

change

ignoring aspect ratio

to

preserving the aspect ratio

Island Usurper’s picture

The Outside option isn't for making square thumbnails. The new Scale and Crop is perfect for making square thumbnails.

Scaling to the outside dimensions lets you create images that are constrained in one dimension, but the actual geometry of the image determines which dimension is constrained. Really wide images are set to a certain height, but at the same time, really tall images are set to a certain width. It's like Scale and Crop without the crop. And that's different from what the new Scale does.

The slide frame analogy is a good one. The dimensions of the slide are what you would enter, and it would scale the image to completely fill it. But you would still see the entire image when it is displayed.

mindgame’s picture

Scale with inside/outside dimensions was very useful and flexible! I love it!!
Imagine this case: For a table view of applicants you want to have square thumbnails of their photos, but as the face is usually in the upper part of the image I used this preset with imagecache 1.x:

1. "Deprecated" Scale (width: 50, height: 50, fit: Outside dimensions [i.e. no dimension less than 50])
2. Crop (width: 50, height: 50, xoffset: center, yoffset: top [i.e. square from upper middle])

I donate a beer for the first who can tell me how to accomplish exactly the same clipping with only the actions of version 2.1 (excluding my beloved deprecated).
The closest alternative I could find is this:

1. Scale And Crop (width: 50, height: 70 [min. width and min. height])
2. Crop (width: 50, height: 50, xoffset: center, yoffset: top [same as for 1.x])

I have compared the thumbnails from both presets side by side in my table view.
As for the second approach faces are getting a little bigger, but the disadvantage is that for persons too close to the margin the face is cut.
This cannot happen with "Deprecated Scale (outside dimensions)", because when the image format is landscape it takes the full height and for portrait the full width.

My conclusion is that it is good to have one fast action "Scale And Crop", but the Deprecated Scale is very flexible and currently there is no replacement. As the new "Scale" replaces only the "Deprecated Scale (inside dimensions)" why not add an "Outside Scale", so we don't lose that possiblity.

Gabriel R.’s picture

I am still on 1.x and find the "fit to outside" option very useful too. Now I'm scared of upgrading to 2.x :-)

PS: But I am sure the hope to have the crop from center bug fixed will push me.

crosstopher’s picture

From my testing, it sounds like everyone's right here, with a nod to HansBKK (#9) who mentions the poor description.

The problem as I see it is that the "Scale and Crop" is improperly described.. it does in fact "preserve aspect ratio" not ignore it, making is the exact replacement for "Outside Scale"+"Crop",.. while the regular "Scale" functions like the old "Inside Scale"..

So go try it despite the bad description before we call keep clamoring for the 'Deprecated Scale'.

HansBKK’s picture

Crosstopher,

What you say is true, but doesn't mean the outside scale should be removed.

If the only use for outside scale was to use it in conjunction with crop there would be no need to "undeprecate it". However there are, as Island Usurper points out (#10), those who want the scale without the crop, and thus removing outside scale would be a loss of functionality.

Unless I've missed something, which is entirely possible.

o0MAV0o’s picture

I've just started playing with this module and found the following preset works to scale any sized image to 100px by 100px

Action ----- Settings
Crop ---------- width: 100, height: 100, xoffset: center, yoffset: center

I'm using this module with Imagefield Gallery.

svilen’s picture

Title: Retaining inside/outside dimensions option in 2.1? » Crop square thumbnails saving aspect ratio
Version: 5.x-2.x-dev » 6.x-2.x-dev

Hello

I achieved square thumbnails without ignored aspect ratio with new action

I added to imagecache_actions.inc file this functions


/**
 * ImageCache Crop Square
 */
function imagecache_crop_square_form($data) {
  $data += array(
    'width' => '',
    'height' => '',
  );
  $form['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $data['width'],
    '#description' => t('Enter a width in pixels or as a percentage. i.e. 500 or 80%.'),
  );
  $form['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => $data['height'],
    '#description' => t('Enter a height in pixels or as a percentage. i.e. 500 or 80%.'),
  );
  return $form;
}

function theme_imagecache_crop_square($element) {
  $data = $element['#value'];
  return 'width: '. $data['width'] .', height: '. $data['height'];
}

function imagecache_crop_square_image(&$image, $data) {
    // Calculate the coordinates to crop from
    if ($image->info['height'] < $image->info['width']) {
      $cropSize = $image->info['height'];
      $cropX = (int) (($image->info['width'] - $image->info['height'])/2);
      $cropY = 0;
    }
    else {
      $cropSize = $image->info['width'];
      $cropX = 0;
      $cropY = (int) (($image->info['height'] - $image->info['width'])/2);
    }
    // Crop the image to a square as large as possible, centered in the image
    $state = imageapi_image_crop($image, $cropX, $cropY, $cropSize, $cropSize);
    if ($state) {
      // Resize the square image to the 'width' of the thumbnail setting (so height is essentially ignored)
      $state = imageapi_image_resize($image, $data['width'], $data['height']);        
    }
  if (!$state) {
      watchdog('imagecache', 'imagecache_crop_square failed. image: %image, data: %data.', array('%path' => $image, '%data' => print_r($data, true)), WATCHDOG_ERROR);
    return false;
  }
  return true;
}


and two things in imagecache.module

new item in imagecache_theme()

    'imagecache_crop_square' => array(
      'file' => 'imagecache_actions.inc',
      'arguments' => array('element' => NULL),
    ),

and new action in imagecache_imagecache_actions()

    'imagecache_crop_square' => array(
      'name' => 'Crop Square',
      'description' => 'Crop an image to the rectangle specified by the given offsets and dimensions (saving aspect ratio). ',
      'file' => 'imagecache_actions.inc',
    ),

Then clear the cache and try the new action

Hope this will be in 2.1 release of this great module

HansBKK’s picture

Title: Crop square thumbnails saving aspect ratio » Retaining outside dimensions option in 2.1

@svilen - This thread pretty clearly established that creating square thumbnails is just one aspect of the function being deprecated, and in fact the current option set without the deprecated outside function has no problem satisfying this need.

I don't understand what your code is doing, but please start a new issue for it. I would also suggest trying to clearly explain what problem your code is solving - in other words, why is it needed?

I've reset the wording on this issue back to the main topic of this discussion (as it's evolved), which is asking for all the current "outside crop" functionality to not be discarded with the function marked to be deprecated.

svilen’s picture

I am sorry for the wrong post, i will create a new one explaining the idea of my code

OpenChimp’s picture

+1

Just adding my vote to keep the Outside Dimensions feature or something similar. I've always found it very useful (doing basically the same thing as mindgame), and it seems like noone on this thread has a comparable solution for how to create square thumbnails from various sized images using the non deprecated actions.

I hope that this sticks around or that a clear alternative method is provided for creating these type of images.

Thanks

danielb’s picture

Seems to me that the Scale & Crop feature does not at all do what I want, and if the maintainers of this module think it is appropriate for making perfect thumbnails, then they do not understand how flexible this module can be, and just what people have been doing with it.

I have found the Drupal 6 version of image cache quite frustrating - particularly seeing 'deprecated' on the most useful imagecache feature.

I forsee a new module being created called "Imagecache Classic".

HansBKK’s picture

@danielb - it's not as if the functionality has actually gone away, or the maintainers have marked this "won't fix". The whole idea of this issue is to give information on why this feature should be kept, not to belittle or berate the developers, from whose work we're benefiting solely because of their generosity. Consider the fact that there may be reasons for deprecating this function that we don't yet know about, beyond their failing to consider all possible use cases, and even if not, that's entirely understandable.

Regarding whatever other frustrations you may be experiencing with the module, it might be helpful if you post specific details as a (new and different) support request in the queue. However I would suggest you're more likely to get help (not only from the maintaineres) if you could try to word your request a bit more positively and give more specific concrete details on the issues, ideally with step-by-step instructions on how to re-create what you're seeing.

HansBKK’s picture

To summarize my understanding from the above thread, Scale & Crop will give square thumbnails from non-square photos while maintaining proper aspect ratio, but the deprecated outside dimensions option allows for a better result when you want to keep as much as possible of the original image.

There are other uses for the outside dimensions option, and it would be great if people could post details on those rather than just keeping reiterating the square thumbnails issue; I personally think that's a dead horse that doesn't need any more flogging.

In the meantime, let me reiterate to dopry and drewish, on behalf of the whole community, our enormous gratitude for your and the others' hard work in creating and maintaining this most excellent module.

danielb’s picture

I don't need help mate, just giving a little motivational kick in the backside. It shows I actually care. :D

3goose’s picture

Here is a non-square example of where i use outside dimension scaling: I am constantly making sets of images that all have the same dimensions (for galleries, carousels, etc.) from original images that have different aspect ratios, including landscape and portrait oriented originals. I first set the exact dimensions i want, scaling to outside dimensions, then i crop to the same dimensions. This way all of my images are the same size, they retain the maximum amount of the photo possible, and never have black lines on the sides because the aspect ratio changed!

I can't see how you could do this without outside dimension scaling. PLEASE DON'T REMOVE THIS VERY USEFUL FEATURE! (Or explain how i can do the same with the other tools.)

benovic’s picture

word.

I would very much like to see a howto for a preset that is capable of returning a 75x75 square without borders for both: 100x400 images and 400x100.

PLEASE post a howto for this without using the deprecated scale method.

NecroHill’s picture

+1 to keep this feature

papandos’s picture

I would very much like to see a howto for a preset that is capable of returning a 75x75 square without borders for both: 100x400 images and 400x100.

PLEASE post a howto for this without using the deprecated scale method.

+1. Without cutting of 25% of the image, because "crop width: 75, height: 75, xoffset: center, yoffset: center" cuts 25 sometimes very important pixels of the such small image. And without black empty area.

Moreover: nobody knows the dimensions of the from other users uploaded images. It would be a harmless problem, if the original image is 100x400. What to do, if the image is 2500x500 (or 500x2500) pixels ???

I thought, it can be solved with "crop- rotate 90´- crop - rotate 270´- scale", but no, it doesn't. I've lost more than 5 hours today with testing of all possible combinations. But nothing helpes.

Do the maintainer know, how this should go without deprecated functionality?

mrwendell’s picture

+1 for keeping outside dimension on the scale (the depreciated Action) indefinitely.

Our user case is for a non-profit magazine's online publishing platform. For the teaser we present the article with a thumbnail of the lead image.

Now the editors are very picky about how the thumbnail is determined and the volunteer staff creating the articles can upload some very odd aspect ratios.

To get around this I first use the outside scale (e.g. 120px minimum outside) then a javascript crop (100 X 100) so the editors can come in play with the thumbnail for hours on end. For some pathological image ratios (e.g. 1000x100) doing any sort of regular scale (i.e. inside dimension) then a square crop will reek havoc (Unless I am missing something here).

Asking people to prepare images properly ahead of time is not possible, I need to correct for as many mistakes server side as possible.

s.Daniel’s picture

It took me manny hours and half a dozend projects to figure out that "Add Scale And Crop - Resize an image to an exact set of dimensions, ignoring aspect ratio." does not distort the image.

So 1. the help text should be changed and 2. outside ratio is a usefull feature.

drewish’s picture

the feature won't be removed.

drewish’s picture

Title: Retaining outside dimensions option in 2.1 » Remove the deprecated status from the outside dimensions scaling
Status: Postponed (maintainer needs more info) » Active
drewish’s picture

drewish’s picture

Okay so trying to evaluate the best way forward on this. I think we can create a new "Outside scale" action and migrate any Inside scales into the current Scale action. Does that sound right? Or maybe the current Scale becomes Inside Scale?

v1nce’s picture

+1 tagging.

Thanks for keeping this functionality moving forward!

Sutharsan’s picture

I use the current scale as outside scale, stopped using Deprecated Scale and did not use Scale and crop because of the confusing description.
I.m.o the way forward would be to use the current Scale as Outside Scale, add an Inside Scale. The Scale And Crop could be deprecated because is can be replaced by combining Inside/Outside Scale and Crop.

Thanks for keeping the inside scale option!

GuillaumeDuveau’s picture

I think we can create a new "Outside scale" action and migrate any Inside scales into the current Scale action. Does that sound right? Or maybe the current Scale becomes Inside Scale? Seems the best scenario to me to obtain a thumbnail while keeping the maximum information and using the whole square.

I'd like to point to another scenario that I think has not been mentionned (NOT using the whole square with the image and putting a background) :
- you have an image of unknown dimensions
- you want to create a square thumb of L pixels that englobes the whole picture and put a colored background C
- you need to know which is greater : width or height
- you scale the width or height to L
- you create a new image which is a square of L pixels with the background C
- you add the image centered on the background

=> Is there any way to do this with ImageCache ? Sorry to hijack that issue.

drewish’s picture

well now that part of imagecache has landed in core (#491456: ImageCache preset API) we really need to get the inside/outside scaling figured out there and then back port it to 6.

drewish’s picture

okay so i think the solution for this is to do a two scale (scale specifying only height, scaling specifying only width) operations and then crop.

tijeika’s picture

+1

Zach Harkey’s picture

+1 for having two scale options. (The need to preserve inside/outside scaling cannot be understated.)

Seems like the easiest thing to do is rename Deprecated Scale to Scale to fit and leave the options as they are.

However, if you really want to break it into two separate actions, what about Scale Longest Side and Scale Shortest Side. These labels are more intuitive than Outside and Inside dimensions, both of which require full descriptions to decode. If it weren't for "Ideal for cropping the result to a square" I would never remember which one I wanted.

GuillaumeDuveau’s picture

@Zach : "Scale shortest side" would be enough. Say you want a square of X pixels. Scale the shortest side to X in action 1 then crop to X,X from the center in action 2.

It's impossible otherwise. If you start to scale one size, you need the other size to be greater or equal to the first one if you want to get a square in the end.

Island Usurper’s picture

guix, I think Zach meant that those two actions would cover all of the functionality that people want. I doubt that they would be used on the same preset.

(Minor quibble: "shorter" and "longer" are more correct grammatically than "shortest" and "longest" because there are only two sides to talk about, not three or more.)

Scale longer side would be used the way the scale action is usually used: to make an image fit entirely within a set of dimensions. Scale shorter side would be used to completely fill up a space, with some possible overhang on two ends. However, which two ends depends on the aspect ratio of the original image and not whether you specify just a width or height to scale to. Saying it this way ought to explain why they were previously called inside and outside scale, respectively.

This sounds like the most intuitive labels for these two actions. I would recommend keeping the note that Scale shorter side is the one that people want for cropping to squares afterwards.

GuillaumeDuveau’s picture

@Island Usurper : seems fine like that !

schedal’s picture

+1 to keep this feature!!!

jhebel’s picture

+1 to keep this feature.

jacobmn’s picture

I have to agree with people asking to keep this. I understand that most of the functionality can be achieved with the new scale and crop option, BUT that leaves out other possibilities that I would still like to be able to use. I do not see this feature as only useful in pre-cropping situations.

For instance, in many cases I want to resize an image (without even cropping it) to fit within a specific set of dimensions. In this example I would use the inside dimension option to ensure that a photo doesn't break out of a pre-sized box - as one would find in many image galleries.

This is the most common example of how I find this feature useful, as I frequently roll my own image galleries using imagefield, imagecache and one or more jquery scripts in combination to achieve different functionality. I find this feature to offer that little extra (necessary) functionality that sometimes people might want to have available.

That said, imagecache offers a lot of options, so maybe I am overlooking one that can achieve the functionality I have just mentioned. Please let me know if I am incorrect on this.

doublejosh’s picture

+1 for keeping.

Using the outside scale for unknown width and height prior to a crop (regardless of shape) has always been my #1 use for this module. Only bummer was that it did not include an "allow upscaling" which means there is at least one scenario that imagecache still cannot accomplish even if the deprecated scale is left in...

Completely fill a fixed space with an image of unknown dimensions when at least one dimension is smaller than the fixed space.

This is pretty much the standard scenario on the web for avatars besides a nasty stretch or throwing in a background.

sydneyshan’s picture

+1 for keeping.

...unless Scale and Crop gets the functionality to specify an X and Y offset/keyword (ie top, center, bottom and left, center, right).

I have just used this Deprecated Scale to scale an image into a square (using Outside dimensions setting), then use Crop to make a landscape image (specifying center, top as X/Y offset values).

This way I can achieve full-frame scale and crop functionality whilest retaining the ability to specify an offset.

rjacobs’s picture

+1 as well - and to sydneyshan's point.

We currently do the exact same thing as sydneyshan, but for a square thumb (while always maintaining the upper-left corner)

As If’s picture

another +1 for keeping. I just ran into another one of those situations where no other approach gave me what I wanted.

antonisar’s picture

+1 remove 'deprecated' word and leave functionality as is. Even if there was a method to replicate the functionality spending hours to find it is impractical especially for new users (not that I found it...)

WorldFallz’s picture

@37

anyone know if this has been taken up for d7 yet or how this might be done in d7?

I hate to waste time on a patch here, when dww is right-- it should be fixed in d7 and whatever that fix is should be backported to this issue.

s.Daniel’s picture

The option is available in d7 but as far as I understand there is nothing really to fix in D6. Just remove the text about deprecated status to reduce confusion and everyon is happy, right?

drewish’s picture

Issue tags: +Novice

Somebody roll a patch to take deprecated and i'll commit it.

SteffenR’s picture

Status: Active » Needs review
FileSize
796 bytes

I rolled a patch against 6.x-2.0-beta12 - to clarify the functionality i added a short description and called the action "Exact Scale" ..

SteffenR’s picture

i rerolled it again - "Scale to fit" is a more suitable name for the action.. sorry for last one..

fizk’s picture

Issue tags: -Novice +ImageCache 2.x Todo

Marking as ImageCache 2.x Todo.