1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 15:24:37 +02:00

added quality parameter

This commit is contained in:
Oliver Vogel
2013-02-01 18:19:12 +01:00
parent 0981553edc
commit e471063c37
2 changed files with 9 additions and 5 deletions

View File

@@ -82,6 +82,9 @@ $img->pixelate(25);
// save image in desired format
$img->save('public/bar.jpg');
// save image in desired format and quality
$img->save('public/bar.jpg', 60);
// its also possible to chain methods
$img1 = Image::make('public/img1.png');
$img2 = Image::make('public/img2.png');

View File

@@ -387,10 +387,11 @@ class Image
/**
* Returns image type stream
*
* @param string $type gif|png|jpg|jpeg
* @param string $type gif|png|jpg|jpeg
* @param integer quality
* @return string
*/
private function data($type = null)
private function data($type = null, $quality = 90)
{
ob_start();
@@ -406,7 +407,7 @@ class Image
default:
case 'jpg':
case 'jpeg':
@imagejpeg($this->resource, null, 90);
@imagejpeg($this->resource, null, $quality);
break;
}
@@ -456,10 +457,10 @@ class Image
* @param string $path
* @return Image
*/
public function save($path = null)
public function save($path = null, $quality = 90)
{
$path = is_null($path) ? ($this->dirname .'/'. $this->basename) : $path;
file_put_contents($path, $this->data($this->filesystem->extension($path)));
file_put_contents($path, $this->data($this->filesystem->extension($path), $quality));
return $this;
}