You are here

function photos_image_crop in Album Photos 6.2

3 calls to photos_image_crop()
photos_admin_update in inc/photos.admin.inc
photos_get_thumb in ./photos.module
photos_image_date in ./photos.module

File

./photos.module, line 881

Code

function photos_image_crop($v = array()) {
  $i = image_get_info($v['path']);
  if ($i || !empty($i['extension'])) {
    $a = 0;
    $n = end(explode('/', $v['path']));
    if (!$v['size']) {
      $info = photos_upload_info(0);
      $size = $info['size'];
    }
    else {
      $size = $v['size'];
    }
    $thumbpath = photos_check_path('thumb', array(
      $v['path'],
      $v['fid'],
    ), $v['privacy']);
    foreach ($size as $t) {
      if ($i['width'] > $t['w'] || $i['height'] > $t['h']) {
        if (!$t['l']) {
          $thumb = $t['w'] . 'x' . $t['h'] . '_' . $t['r'] . '_thumb_';
        }
        else {
          $thumb = $t['l'];
        }
        switch ($t['r']) {
          case 'scale':
            image_scale_and_crop($v['path'], $thumbpath . '/' . $thumb . $n, $t['w'], $t['h']);
            $a++;
            break;
          case 'resize':
            image_resize($v['path'], $thumbpath . '/' . $thumb . $n, $t['w'], $t['h']);
            $a++;
            break;
          case 'crop':
          default:
            image_scale($v['path'], $thumbpath . '/' . $thumb . $n, $t['w'], $t['h']);
            $a++;
            break;
        }
      }
    }
  }
  return $a;
}