mirror of
https://github.com/Intervention/image.git
synced 2025-09-02 02:12:37 +02:00
added ImageNotWritableException
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Exception;
|
||||
|
||||
class ImageNotWritableException extends \RuntimeException
|
||||
{
|
||||
# nothing to override
|
||||
}
|
@@ -336,6 +336,7 @@ class Image
|
||||
// catch legacy call
|
||||
if (is_array($width)) {
|
||||
$dimensions = $width;
|
||||
|
||||
return $this->legacyResize($dimensions);
|
||||
}
|
||||
|
||||
@@ -427,6 +428,7 @@ class Image
|
||||
{
|
||||
$width = array_key_exists('width', $dimensions) ? intval($dimensions['width']) : null;
|
||||
$height = array_key_exists('height', $dimensions) ? intval($dimensions['height']) : null;
|
||||
|
||||
return $this->resize($width, $height, true);
|
||||
}
|
||||
|
||||
@@ -638,6 +640,7 @@ class Image
|
||||
// catch legacy call
|
||||
if (is_array($width)) {
|
||||
$dimensions = $width;
|
||||
|
||||
return $this->legacyGrab($dimensions);
|
||||
}
|
||||
|
||||
@@ -1270,6 +1273,7 @@ class Image
|
||||
$data = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -1388,11 +1392,9 @@ class Image
|
||||
}
|
||||
|
||||
if (isset($allocatedColor)) {
|
||||
|
||||
return $allocatedColor;
|
||||
|
||||
} elseif (isset($r) && isset($g) && isset($b)) {
|
||||
|
||||
return imagecolorallocatealpha($this->resource, $r, $g, $b, $a);
|
||||
|
||||
} else {
|
||||
@@ -1411,7 +1413,11 @@ class Image
|
||||
public function save($path = null, $quality = 90)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
@@ -1522,8 +1528,10 @@ class Image
|
||||
if (get_resource_type($input) != 'gd') {
|
||||
throw new Exception\InvalidImageResourceException;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user