Remove the deprecated status from the outside dimensions scaling

kyla - June 27, 2008 - 00:46
Project:ImageCache
Version:6.x-2.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

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.

#1

erikhopp - June 27, 2008 - 00:49

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

#2

drewish - June 28, 2008 - 22:31
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?

#3

coreyp_1 - July 1, 2008 - 03:09

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.

#4

alexh - July 17, 2008 - 13:17

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!

#5

Island Usurper - August 5, 2008 - 16:02

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.

#6

paulkidd - August 11, 2008 - 01:29

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

#7

starbow - August 15, 2008 - 16:12

+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.

#8

droople - August 21, 2008 - 17:08

+1

please keep

#9

HansBKK - September 28, 2008 - 00:41

+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

#10

Island Usurper - September 25, 2008 - 15:45

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.

#11

mindgame - September 27, 2008 - 21:05

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.

#12

Gabriel Radic - October 4, 2008 - 21:31

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.

#13

crosstopher - October 6, 2008 - 02:01

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'.

#14

HansBKK - October 6, 2008 - 04:52

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.

#15

o0MAV0o - October 14, 2008 - 03:31

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.

#16

svilen - October 19, 2008 - 16:33
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

#17

HansBKK - October 20, 2008 - 08:42
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.

#18

svilen - October 20, 2008 - 11:05

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

#19

MikeyLikesIt - October 23, 2008 - 06:39

+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

#20

danielb - October 24, 2008 - 02:47

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".

#21

HansBKK - October 24, 2008 - 07:48

@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.

#22

HansBKK - October 24, 2008 - 07:49

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.

#23

danielb - October 26, 2008 - 04:01

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

#24

3goose - November 27, 2008 - 01:16

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.)

#25

Ben__ - November 27, 2008 - 16:38

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.

#26

NecroHill - December 28, 2008 - 13:36

+1 to keep this feature

#27

papandos - January 9, 2009 - 02:38

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?

#28

mrwendell - February 20, 2009 - 16:33

+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.

#29

s.Daniel - March 14, 2009 - 21:10

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.

#30

drewish - March 15, 2009 - 22:39

the feature won't be removed.

#31

drewish - April 29, 2009 - 20:42
Title:Retaining outside dimensions option in 2.1» Remove the deprecated status from the outside dimensions scaling
Status:postponed (maintainer needs more info)» active

#32

drewish - May 1, 2009 - 14:09

#33

drewish - May 1, 2009 - 17:16

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?

#34

v1nce - May 10, 2009 - 03:58

+1 tagging.

Thanks for keeping this functionality moving forward!

#35

Sutharsan - June 7, 2009 - 13:52

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!

#36

guix - July 13, 2009 - 12:56

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.

#37

drewish - July 13, 2009 - 18:17

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.

#38

drewish - July 21, 2009 - 02:26

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.

#39

tijeika - September 13, 2009 - 23:22

+1

#40

Zach Harkey - September 29, 2009 - 21:12

+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.

#41

guix - October 22, 2009 - 15:04

@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.

#42

Island Usurper - October 22, 2009 - 18:45

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.

#43

guix - October 23, 2009 - 10:17

@Island Usurper : seems fine like that !

#44

schedal - November 29, 2009 - 01:15

+1 to keep this feature!!!

 
 

Drupal is a registered trademark of Dries Buytaert.