You are here

function _collageformatter_upscaling_check in Collage Formatter 7

Checks for upscaled images and returns the scaling factor.

1 call to _collageformatter_upscaling_check()
collageformatter_render_collage in ./collageformatter.module
Returns renderable array of collages.

File

./collageformatter.module, line 948
Main file for Collage Formatter module.

Code

function _collageformatter_upscaling_check($box, $settings) {
  $scale1 = $scale2 = 1;
  if ($box['box_type'] == 'box') {
    $scale1 = _collageformatter_upscaling_check($box[1], $settings);
    $scale2 = _collageformatter_upscaling_check($box[2], $settings);
  }
  elseif ($box['box_type'] == 'image') {
    $width = $box['total_width'] - 2 * $settings['border_size'] - $settings['gap_size'];
    $height = $box['total_height'] - 2 * $settings['border_size'] - $settings['gap_size'];
    if ($box['width'] < $width) {
      $scale1 = $box['width'] / $width;
    }
    if ($box['height'] < $height) {
      $scale1 = $box['height'] / $height;
    }
  }
  return $scale1 <= $scale2 ? $scale1 : $scale2;
}