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:
@@ -82,6 +82,9 @@ $img->pixelate(25);
|
|||||||
// save image in desired format
|
// save image in desired format
|
||||||
$img->save('public/bar.jpg');
|
$img->save('public/bar.jpg');
|
||||||
|
|
||||||
|
// save image in desired format and quality
|
||||||
|
$img->save('public/bar.jpg', 60);
|
||||||
|
|
||||||
// its also possible to chain methods
|
// its also possible to chain methods
|
||||||
$img1 = Image::make('public/img1.png');
|
$img1 = Image::make('public/img1.png');
|
||||||
$img2 = Image::make('public/img2.png');
|
$img2 = Image::make('public/img2.png');
|
||||||
|
@@ -387,10 +387,11 @@ class Image
|
|||||||
/**
|
/**
|
||||||
* Returns image type stream
|
* Returns image type stream
|
||||||
*
|
*
|
||||||
* @param string $type gif|png|jpg|jpeg
|
* @param string $type gif|png|jpg|jpeg
|
||||||
|
* @param integer quality
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function data($type = null)
|
private function data($type = null, $quality = 90)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@@ -406,7 +407,7 @@ class Image
|
|||||||
default:
|
default:
|
||||||
case 'jpg':
|
case 'jpg':
|
||||||
case 'jpeg':
|
case 'jpeg':
|
||||||
@imagejpeg($this->resource, null, 90);
|
@imagejpeg($this->resource, null, $quality);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,10 +457,10 @@ class Image
|
|||||||
* @param string $path
|
* @param string $path
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public function save($path = null)
|
public function save($path = null, $quality = 90)
|
||||||
{
|
{
|
||||||
$path = is_null($path) ? ($this->dirname .'/'. $this->basename) : $path;
|
$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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user