You are here

function _imagepicker_watermark_make_image in Image Picker 7

Same name and namespace in other branches
  1. 6.2 imagepicker.imagefuncs.inc \_imagepicker_watermark_make_image()

Adapted from watermark module.

Parameters

filepath $file:

Return value

array $img_info

1 call to _imagepicker_watermark_make_image()
imagepicker_watermark_do in ./imagepicker.imagefuncs.inc
Adapted from watermark module.

File

./imagepicker.imagefuncs.inc, line 216
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function _imagepicker_watermark_make_image($file) {
  if (!file_exists($file)) {
    drupal_set_message(t('Image file %file not found.', array(
      '%file' => $file,
    )), 'error');
    return FALSE;
  }
  $type = exif_imagetype($file);
  switch ($type) {
    case IMAGETYPE_GIF:
      $type = 'gif';
      break;
    case IMAGETYPE_JPEG:
      $type = 'jpeg';
      break;
    case IMAGETYPE_PNG:
      $type = 'png';
      break;
    case IMAGETYPE_WBMP:
      $type = 'wbmp';
      break;
    default:

      // Unsupported type
      drupal_set_message(t('Image file %file is an unsupported format type=%type.', array(
        '%file' => $file,
        '%type' => $type,
      )), 'error');
      return FALSE;
  }
  $function = 'imagecreatefrom' . $type;
  $handle = $function($file);
  if (!$handle) {
    drupal_set_message(t('Failed to create handle for image file %file via function %function.', array(
      '%file' => $file,
      '%function' => $function,
    )), 'error');
    return FALSE;
  }

  // create image info
  $img_info = array(
    'type' => $type,
    'truecolor' => imageistruecolor($handle),
    'colors' => imagecolorstotal($handle),
    'handle' => $handle,
    'width' => imagesx($handle),
    'height' => imagesy($handle),
  );
  return $img_info;
}