Skip to content

Commit 67a692b

Browse files
Merge pull request #76 from TheM1984/master
Replaced general Exception with own ImageResizeException
2 parents 7c51c84 + 6d9a440 commit 67a692b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/ImageResize.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Eventviva;
44

5-
use \Exception;
6-
75
/**
86
* PHP class to resize and scale images
97
*/
@@ -46,7 +44,7 @@ class ImageResize
4644
*
4745
* @param string $image_data
4846
* @return ImageResize
49-
* @throws \exception
47+
* @throws ImageResizeException
5048
*/
5149
public static function createFromString($image_data)
5250
{
@@ -59,14 +57,14 @@ public static function createFromString($image_data)
5957
*
6058
* @param string $filename
6159
* @return ImageResize
62-
* @throws \Exception
60+
* @throws ImageResizeException
6361
*/
6462
public function __construct($filename)
6563
{
6664
$image_info = @getimagesize($filename);
6765

6866
if (!$image_info) {
69-
throw new \Exception('Could not read file');
67+
throw new ImageResizeException('Could not read file');
7068
}
7169

7270
list (
@@ -94,12 +92,12 @@ public function __construct($filename)
9492
break;
9593

9694
default:
97-
throw new \Exception('Unsupported image type');
95+
throw new ImageResizeException('Unsupported image type');
9896
break;
9997
}
100-
98+
10199
if (!$this->source_image) {
102-
throw new \Exception('Could not load image');
100+
throw new ImageResizeException('Could not load image');
103101
}
104102

105103
return $this->resize($this->getSourceWidth(), $this->getSourceHeight());
@@ -222,7 +220,7 @@ public function save($filename, $image_type = null, $quality = null, $permission
222220
if ($permissions) {
223221
chmod($filename, $permissions);
224222
}
225-
223+
226224
imagedestroy($dest_image);
227225

228226
return $this;
@@ -575,3 +573,8 @@ function imageflip($image, $mode) {
575573
imagedestroy($temp_image);
576574
}
577575
}
576+
577+
/**
578+
* PHP Exception used in the ImageResize class
579+
*/
580+
class ImageResizeException extends \Exception {}

0 commit comments

Comments
 (0)