function _imce_watermark::create_image in IMCE Watermark 7
This little function allows you to create an image based on the popular image types without worrying about what it is: http://www.php.net/manual/ru/function.imagecreatefromjpeg.php#110547
Parameters
type $filepath:
Return value
boolean
1 call to _imce_watermark::create_image()
File
- ./
imce_watermark.module, line 555 - Adding watermark at IMCE image uploading.
Class
Code
function create_image($filepath, $set_image_type = FALSE) {
$img_type = $this->image_type;
$type = exif_imagetype($filepath);
// [] if you don't have exif you could use getImageSize()
$allowedTypes = array(
1,
// [] gif
2,
// [] jpg
3,
// [] png
6,
);
if (!in_array($type, $allowedTypes)) {
return false;
}
switch ($type) {
case 1:
$img_type = 'gif';
$im = imageCreateFromGif($filepath);
break;
case 2:
$img_type = 'jpg';
$im = imageCreateFromJpeg($filepath);
break;
case 3:
$img_type = 'png';
$im = imageCreateFromPng($filepath);
break;
case 6:
$img_type = 'bmp';
$im = imageCreateFromBmp($filepath);
break;
}
if ($set_image_type) {
$this->image_type = $img_type;
}
return $im;
}