function _imagepicker_watermark_make_image in Image Picker 6.2
Same name and namespace in other branches
- 7 imagepicker.imagefuncs.inc \_imagepicker_watermark_make_image()
Adapted from watermark module.
1 call to _imagepicker_watermark_make_image()
- imagepicker_watermark_do in ./
imagepicker.imagefuncs.inc - Adapted from watermark module.
File
- ./
imagepicker.imagefuncs.inc, line 200 - Image functions for imagepicker.
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;
}