mirror of
https://github.com/Intervention/image.git
synced 2025-09-02 18:32:56 +02:00
bugfix
This commit is contained in:
@@ -1408,7 +1408,7 @@ class Image
|
|||||||
*/
|
*/
|
||||||
public function encode($format = null, $quality = 90)
|
public function encode($format = null, $quality = 90)
|
||||||
{
|
{
|
||||||
$format = is_null($format) ? $this->type : $format;
|
$format = is_null($format) ? $this->mime : $format;
|
||||||
|
|
||||||
if ($quality < 0 || $quality > 100) {
|
if ($quality < 0 || $quality > 100) {
|
||||||
throw new Exception\ImageQualityException('Quality of image must range from 0 to 100.');
|
throw new Exception\ImageQualityException('Quality of image must range from 0 to 100.');
|
||||||
@@ -1422,6 +1422,7 @@ class Image
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'gif':
|
case 'gif':
|
||||||
|
case 'image/gif':
|
||||||
case IMAGETYPE_GIF:
|
case IMAGETYPE_GIF:
|
||||||
imagegif($this->resource);
|
imagegif($this->resource);
|
||||||
$this->type = IMAGETYPE_GIF;
|
$this->type = IMAGETYPE_GIF;
|
||||||
@@ -1429,6 +1430,7 @@ class Image
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'png':
|
case 'png':
|
||||||
|
case 'image/png':
|
||||||
case IMAGETYPE_PNG:
|
case IMAGETYPE_PNG:
|
||||||
$quality = round($quality / 11.11111111111); // transform quality to png setting
|
$quality = round($quality / 11.11111111111); // transform quality to png setting
|
||||||
imagealphablending($this->resource, false);
|
imagealphablending($this->resource, false);
|
||||||
@@ -1441,6 +1443,8 @@ class Image
|
|||||||
default:
|
default:
|
||||||
case 'jpg':
|
case 'jpg':
|
||||||
case 'jpeg':
|
case 'jpeg':
|
||||||
|
case 'image/jpg':
|
||||||
|
case 'image/jpeg':
|
||||||
case IMAGETYPE_JPEG:
|
case IMAGETYPE_JPEG:
|
||||||
imagejpeg($this->resource, null, $quality);
|
imagejpeg($this->resource, null, $quality);
|
||||||
$this->type = IMAGETYPE_JPEG;
|
$this->type = IMAGETYPE_JPEG;
|
||||||
@@ -1824,6 +1828,7 @@ class Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->resource = $resource;
|
$this->resource = $resource;
|
||||||
|
$this->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $string);
|
||||||
$this->width = imagesx($this->resource);
|
$this->width = imagesx($this->resource);
|
||||||
$this->height = imagesy($this->resource);
|
$this->height = imagesy($this->resource);
|
||||||
$this->original['width'] = $this->width;
|
$this->original['width'] = $this->width;
|
||||||
|
@@ -161,6 +161,7 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertInternalType('int', $img->height);
|
$this->assertInternalType('int', $img->height);
|
||||||
$this->assertEquals($img->width, 800);
|
$this->assertEquals($img->width, 800);
|
||||||
$this->assertEquals($img->height, 600);
|
$this->assertEquals($img->height, 600);
|
||||||
|
$this->assertEquals($img->mime, 'image/jpeg');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStaticCallMakeFromResource()
|
public function testStaticCallMakeFromResource()
|
||||||
|
Reference in New Issue
Block a user