You are here

function image_focus_get_focal_point in Image Focus Crop 7

Same name and namespace in other branches
  1. 6 image_focus.module \image_focus_get_focal_point()

Returns the focal point of the image.

1 call to image_focus_get_focal_point()
image_focus_scale_and_crop_effect in ./image_focus.module
Image effect callback for image_focus_scald_and_crop.

File

./image_focus.module, line 43
Image Focus Crop module.

Code

function image_focus_get_focal_point($image) {
  $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
  $function = 'imagecreatefrom' . $extension;
  if (function_exists($function) && ($resource = $function($image->source))) {

    // Try different algorithms.
    if ($image->info['file_size'] <= variable_get('image_focus_face_detection_maxsize', 50 * 1024) && ($result = image_focus_get_focal_point_face_detection($resource))) {
      return $result;
    }
    if ($result = image_focus_get_focal_point_entropy($resource)) {
      return $result;
    }
  }
  return array(
    $image->info['width'] / 2,
    $image->info['height'] / 2,
  );
}