1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-03 02:42:45 +02:00

added ImageNotWritableException

This commit is contained in:
Oliver Vogel
2013-09-24 16:55:17 +02:00
parent fcefaf097e
commit 8242dee952
3 changed files with 64 additions and 48 deletions

View File

@@ -0,0 +1,8 @@
<?php
namespace Intervention\Image\Exception;
class ImageNotWritableException extends \RuntimeException
{
# nothing to override
}

View File

@@ -336,6 +336,7 @@ class Image
// catch legacy call // catch legacy call
if (is_array($width)) { if (is_array($width)) {
$dimensions = $width; $dimensions = $width;
return $this->legacyResize($dimensions); return $this->legacyResize($dimensions);
} }
@@ -427,6 +428,7 @@ class Image
{ {
$width = array_key_exists('width', $dimensions) ? intval($dimensions['width']) : null; $width = array_key_exists('width', $dimensions) ? intval($dimensions['width']) : null;
$height = array_key_exists('height', $dimensions) ? intval($dimensions['height']) : null; $height = array_key_exists('height', $dimensions) ? intval($dimensions['height']) : null;
return $this->resize($width, $height, true); return $this->resize($width, $height, true);
} }
@@ -638,6 +640,7 @@ class Image
// catch legacy call // catch legacy call
if (is_array($width)) { if (is_array($width)) {
$dimensions = $width; $dimensions = $width;
return $this->legacyGrab($dimensions); return $this->legacyGrab($dimensions);
} }
@@ -1270,6 +1273,7 @@ class Image
$data = ob_get_contents(); $data = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $data; return $data;
} }
@@ -1388,11 +1392,9 @@ class Image
} }
if (isset($allocatedColor)) { if (isset($allocatedColor)) {
return $allocatedColor; return $allocatedColor;
} elseif (isset($r) && isset($g) && isset($b)) { } elseif (isset($r) && isset($g) && isset($b)) {
return imagecolorallocatealpha($this->resource, $r, $g, $b, $a); return imagecolorallocatealpha($this->resource, $r, $g, $b, $a);
} else { } else {
@@ -1411,7 +1413,11 @@ class Image
public function save($path = null, $quality = 90) public function save($path = null, $quality = 90)
{ {
$path = is_null($path) ? ($this->dirname .'/'. $this->basename) : $path; $path = is_null($path) ? ($this->dirname .'/'. $this->basename) : $path;
file_put_contents($path, $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality)); $saved = @file_put_contents($path, $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality));
if ($saved === false) {
throw new Exception\ImageNotWritableException;
}
return $this; return $this;
} }
@@ -1427,7 +1433,7 @@ class Image
*/ */
public function exif($key = null) public function exif($key = null)
{ {
if (!function_exists('exif_read_data')) { if (! function_exists('exif_read_data')) {
throw new Exception\ExifFunctionsNotAvailableException; throw new Exception\ExifFunctionsNotAvailableException;
} }
@@ -1522,8 +1528,10 @@ class Image
if (get_resource_type($input) != 'gd') { if (get_resource_type($input) != 'gd') {
throw new Exception\InvalidImageResourceException; throw new Exception\InvalidImageResourceException;
} }
return true; return true;
} }
return false; return false;
} }