JBZoo\Image\Image::saveAs PHP Method

saveAs() public method

Save an image The resulting format will be determined by the file extension.
public saveAs ( string $filename, null | integer $quality = null )
$filename string If omitted - original file will be overwritten
$quality null | integer Output image quality in percents 0-100
    public function saveAs($filename, $quality = null)
    {
        if (!$filename) {
            throw new Exception('Empty filename to save image');
        }
        $dir = FS::dirname($filename);
        if (is_dir($dir)) {
            $this->_save($filename, $quality);
        } else {
            throw new Exception('Target directory "' . $dir . '" not exists');
        }
        return $this;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param $file
  * @return array
  */
 public function uploadScreenShot3($file)
 {
     $name = Str::random() . '.' . strtolower($file->ext);
     $image = new Image($file->image);
     $image->saveAs(PATH_PUBLIC . '/images/' . $name, 100);
     return array('UploadScreenShot3Result' => $image->getUrl());
 }
All Usage Examples Of JBZoo\Image\Image::saveAs