mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 12:41:23 +02:00
added quality param for png format
This commit is contained in:
@@ -666,6 +666,10 @@ class Image
|
||||
*/
|
||||
private function data($type = null, $quality = 90)
|
||||
{
|
||||
if ($quality < 0 || $quality > 100) {
|
||||
throw new Exception('Quality of image must range from 0 to 100.');
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
switch (strtolower($type)) {
|
||||
@@ -674,9 +678,10 @@ class Image
|
||||
break;
|
||||
|
||||
case 'png':
|
||||
$quality = round($quality / 11.11111111111); // transform quality to png setting
|
||||
@imagealphablending($this->resource, false);
|
||||
@imagesavealpha($this->resource, true);
|
||||
@imagepng($this->resource);
|
||||
@imagepng($this->resource, null, $quality);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -335,6 +335,18 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
||||
$img->save($save_as);
|
||||
$this->assertFileExists($save_as);
|
||||
@unlink($save_as);
|
||||
|
||||
$save_as = 'public/test2.png';
|
||||
$img = $this->getTestImage();
|
||||
$img->save($save_as, 80);
|
||||
$this->assertFileExists($save_as);
|
||||
@unlink($save_as);
|
||||
|
||||
$save_as = 'public/test2.jpg';
|
||||
$img = $this->getTestImage();
|
||||
$img->save($save_as, 0);
|
||||
$this->assertFileExists($save_as);
|
||||
@unlink($save_as);
|
||||
}
|
||||
|
||||
public function testStringConversion()
|
||||
|
Reference in New Issue
Block a user