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

added the $format parameter to the save method

This commit is contained in:
Babichev Maxim
2019-06-07 18:04:55 +03:00
parent 5f5e1c8768
commit ab55fbb040

View File

@@ -126,9 +126,10 @@ class Image extends File
* *
* @param string $path * @param string $path
* @param int $quality * @param int $quality
* @param string $format
* @return \Intervention\Image\Image * @return \Intervention\Image\Image
*/ */
public function save($path = null, $quality = null) public function save($path = null, $quality = null, $format = null)
{ {
$path = is_null($path) ? $this->basePath() : $path; $path = is_null($path) ? $this->basePath() : $path;
@@ -138,7 +139,11 @@ class Image extends File
); );
} }
$data = $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality); if ($format === null) {
$format = pathinfo($path, PATHINFO_EXTENSION);
}
$data = $this->encode($format, $quality);
$saved = @file_put_contents($path, $data); $saved = @file_put_contents($path, $data);
if ($saved === false) { if ($saved === false) {