mirror of
https://github.com/Intervention/image.git
synced 2025-01-18 04:38:26 +01:00
throw NotReadableException if try read partially saved image
(getimagesize returns correct size, but image infact is not readable)
This commit is contained in:
parent
e368d26288
commit
69f977b726
@ -25,18 +25,15 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
// define core
|
||||
switch ($info[2]) {
|
||||
case IMAGETYPE_PNG:
|
||||
$core = imagecreatefrompng($path);
|
||||
$this->gdResourceToTruecolor($core);
|
||||
$core = @imagecreatefrompng($path);
|
||||
break;
|
||||
|
||||
case IMAGETYPE_JPEG:
|
||||
$core = imagecreatefromjpeg($path);
|
||||
$this->gdResourceToTruecolor($core);
|
||||
$core = @imagecreatefromjpeg($path);
|
||||
break;
|
||||
|
||||
case IMAGETYPE_GIF:
|
||||
$core = imagecreatefromgif($path);
|
||||
$this->gdResourceToTruecolor($core);
|
||||
$core = @imagecreatefromgif($path);
|
||||
break;
|
||||
|
||||
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
|
||||
$image = $this->initFromGdResource($core);
|
||||
$image->mime = $info['mime'];
|
||||
|
@ -20,6 +20,14 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('image/png', $img->mime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Intervention\Image\Exception\NotReadableException
|
||||
*/
|
||||
public function testMakeFromPathBroken()
|
||||
{
|
||||
$this->manager()->make('tests/images/broken.png');
|
||||
}
|
||||
|
||||
public function testMakeFromString()
|
||||
{
|
||||
$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 |
Loading…
x
Reference in New Issue
Block a user