You are here

function imagecache_proportions_calculate_proportions in Imagecache Proportions 6

Same name and namespace in other branches
  1. 7 imagecache_proportions.module \imagecache_proportions_calculate_proportions()

Helper function to guess if the image is wider, higher or "squarer" taking a look to the looseness.

1 call to imagecache_proportions_calculate_proportions()
theme_imagecache_proportions_formatter_vertical_horizontal in ./imagecache_proportions.module
Depending on the dimensions of the image, we switch the preset chosen.

File

./imagecache_proportions.module, line 131
CCK formatter for imagefields that allows the user to select between 3 different imagecache presets depending on the proportions of the original image uploaded. One preset would be squared for more or less squared images, another for wider images and…

Code

function imagecache_proportions_calculate_proportions($width, $height, $looseness) {
  if ($width == $height || abs($width - $height) < $looseness) {
    return 'squared_preset';
  }
  if ($width > $height) {
    return 'horizontal_preset';
  }
  if ($height > $width) {
    return 'vertical_preset';
  }
}