diff --git a/src/PHPImageWorkshop/ImageWorkshop.php b/src/PHPImageWorkshop/ImageWorkshop.php index 914edd0..6944bdd 100644 --- a/src/PHPImageWorkshop/ImageWorkshop.php +++ b/src/PHPImageWorkshop/ImageWorkshop.php @@ -55,6 +55,10 @@ class ImageWorkshop */ public static function initFromPath($path, $fixOrientation = false) { + if (!file_exists($path)) { + throw new ImageWorkshopException(sprintf('File "%s" not exists.', $path), static::ERROR_IMAGE_NOT_FOUND); + } + if (false === ($imageSizeInfos = @getImageSize($path))) { throw new ImageWorkshopException('Can\'t open the file at "'.$path.'" : file is not readable, did you check permissions (755 / 777) ?', static::ERROR_NOT_READABLE_FILE); } diff --git a/tests/ImageWorkshopTest.php b/tests/ImageWorkshopTest.php index dc5fab8..4f23dc9 100644 --- a/tests/ImageWorkshopTest.php +++ b/tests/ImageWorkshopTest.php @@ -47,7 +47,7 @@ public function testInitFromPath() // test 3 - $this->setExpectedException('PHPImageWorkshop\Exception\ImageWorkshopException'); + $this->setExpectedException('PHPImageWorkshop\Exception\ImageWorkshopException', '', ImageWorkshop::ERROR_IMAGE_NOT_FOUND); $layer = ImageWorkshop::initFromPath('fakePath'); }