Hi

Firstly great module. Can't live without it.

Having a problem with the Aspect Switcher ( I think ). I am trying to resize photos to 169 x 127px ( which is a standard 100x75 aspect ratio ), maintaining aspect ratio by clipping portrait photos. If the photo is a portrait type I want to present the centre portion of the photo i.e. clip off top and bottom borders to get the required aspect ratio.

I have created 2 presets: for landscape photos "more_photos_resize_landscape" and for portrait photos "more_photos_resize_portrait". Screenshots attached. When applied individually both presets do what I expect, and they also display a correct preview of the Drupal droplet image. However when applied via a third preset which is nothing more than an aspect switcher the result doesn't seem to be an application of either of the "sub" presets ( but rather the image ends up as 100 x 127 pixels ). This is also what shows as the preview of the Drupal droplet image on the Aspect Switcher preset.

Is it possible that my 100% in the Crop is being interpreted as 100px when applied via the Aspect Switcher or somesuch ?

Your assistance much appreciated.

Dave

Comments

okeedoak’s picture

I don't know the answer but I'm getting a similar problem. I'm new to the module though so maybe it's something I don't understand. Let me know if you find a solution please. Thanks.

El Bandito’s picture

Having re-visted this problem I now realise that apply the settings for the "more_photos_resize_landscape" preset achieves the required effect when applied to both landscape AND portrait photos, thereby doing away with the need to implement the Aspect Switcher in a separate pre-processing preset. Although this solves my immediate problem it doesn't explain the behaviour of the Aspect Switcher in the example I give.

Cheers

Dave

calebm12’s picture

bumping. I have this EXACT same problem. The aspect switcher it is not respecting the actions set under the H or V presets.

andrewtf’s picture

I'll give this a bump as well, since I'm experiencing the exact same problem, too.

fergal303’s picture

fergal303’s picture

nop

dman’s picture

Status: Active » Fixed

Yeah, found it.

It looks like a few of the original actions do NOT parse the percentages themselves when running, but rely on the caller to have done that for them.
So yeah, 100% came out as just 100.

To fix it I've had to add messy code in to pre-calculate those common variables ... just in case.

  // Run the preset actions ourself. Cannot invoke a preset from the top as it handles filenames, not image objects.
  // ripped from imagecache_build_derivative()
  foreach ($preset['actions'] as $sub_action) {

    // _imagecache_apply_action requires some of the values to be pre-cooked
    // Identified in http://drupal.org/node/626168
    // These actions really should interpret the parameters themselves.
    foreach (array('height', 'width') as $param) {
      if (isset($sub_action['data'][$param])) {
        $sub_action['data'][$param] = _imagecache_percent_filter($sub_action['data'][$param], $image->info[$param]);
      }
    }
    foreach (array('xoffset' => 'width', 'yoffset' => 'height') as $param => $direction) {
      if (isset($sub_action['data'][$param])) {
        $sub_action['data'][$param] = _imagecache_keyword_filter($sub_action['data'][$param], $image->info[$direction], $sub_action['data'][$direction]);
      }
    }
    
    _imagecache_apply_action($sub_action, $image);
  }

fixed in -dev 2.0. (but hold off on an upgrade, it's a bit volatile right now. Moving libraries around.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.