You are here

function imagefield_crop_presize in Imagefield Crop 7.3

Helper func imagefield_crop_presize(). Used to presize image

Parameters

$img_info:

$w:

$h:

1 call to imagefield_crop_presize()
imagefield_crop_widget_preview_process in ./imagefield_crop.module
Impletement imagefield_crop_widget_preview_process().

File

./imagefield_crop.module, line 1368

Code

function imagefield_crop_presize(&$img_info, $w, $h) {
  $nw = $img_info['width'];
  $nh = $img_info['height'];
  if ($nw > $w && $w > 0) {
    $nw = $w;
    $nh = $w / $img_info['width'] * $img_info['height'];
  }
  if ($nh > $h && $h > 0) {
    $nh = $h;
    $nw = $h / $img_info['height'] * $img_info['width'];
  }
  $img_info['xscale'] = $img_info['width'] / $nw;
  $img_info['yscale'] = $img_info['height'] / $nh;
  $img_info['height'] = $nh;
  $img_info['width'] = $nw;
}