You are here

function canvasactions_aspect_image in ImageCache Actions 6

Same name and namespace in other branches
  1. 6.2 canvasactions/canvasactions.inc \canvasactions_aspect_image()

Choose the action and trigger that.

Implementation of hook_image()

Parameters

$image:

$action:

File

./canvasactions.inc, line 992
Helper functions for the text2canvas action for imagecache

Code

function canvasactions_aspect_image(&$image, $action = array()) {
  $ratio_adjustment = 0 + $action['ratio_adjustment'];
  if (!$ratio_adjustment) {
    $ratio_adjustment = 1;
  }
  $aspect = $image->info['width'] / $image->info['height'];

  // width / height * adjustment. If > 1, it's wide.
  $preset_id = $aspect * $ratio_adjustment > 1 ? $action['landscape'] : $action['portrait'];
  $preset = imagecache_preset($preset_id);

  // 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($sub_action, $image);
  }
  return TRUE;
}