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