mirror of
https://github.com/Intervention/image.git
synced 2025-08-11 16:34:00 +02:00
throw NotReadableException if try read partially saved image
(getimagesize returns correct size, but image infact is not readable)
This commit is contained in:
@@ -25,18 +25,15 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
|||||||
// define core
|
// define core
|
||||||
switch ($info[2]) {
|
switch ($info[2]) {
|
||||||
case IMAGETYPE_PNG:
|
case IMAGETYPE_PNG:
|
||||||
$core = imagecreatefrompng($path);
|
$core = @imagecreatefrompng($path);
|
||||||
$this->gdResourceToTruecolor($core);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMAGETYPE_JPEG:
|
case IMAGETYPE_JPEG:
|
||||||
$core = imagecreatefromjpeg($path);
|
$core = @imagecreatefromjpeg($path);
|
||||||
$this->gdResourceToTruecolor($core);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMAGETYPE_GIF:
|
case IMAGETYPE_GIF:
|
||||||
$core = imagecreatefromgif($path);
|
$core = @imagecreatefromgif($path);
|
||||||
$this->gdResourceToTruecolor($core);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -45,6 +42,14 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($core === false) {
|
||||||
|
throw new \Intervention\Image\Exception\NotReadableException(
|
||||||
|
"Unable to read image from file ({$path})."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->gdResourceToTruecolor($core);
|
||||||
|
|
||||||
// build image
|
// build image
|
||||||
$image = $this->initFromGdResource($core);
|
$image = $this->initFromGdResource($core);
|
||||||
$image->mime = $info['mime'];
|
$image->mime = $info['mime'];
|
||||||
|
@@ -20,6 +20,14 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('image/png', $img->mime);
|
$this->assertEquals('image/png', $img->mime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Intervention\Image\Exception\NotReadableException
|
||||||
|
*/
|
||||||
|
public function testMakeFromPathBroken()
|
||||||
|
{
|
||||||
|
$this->manager()->make('tests/images/broken.png');
|
||||||
|
}
|
||||||
|
|
||||||
public function testMakeFromString()
|
public function testMakeFromString()
|
||||||
{
|
{
|
||||||
$str = file_get_contents('tests/images/circle.png');
|
$str = file_get_contents('tests/images/circle.png');
|
||||||
|
BIN
tests/images/broken.png
Normal file
BIN
tests/images/broken.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 B |
Reference in New Issue
Block a user