Exemplo n.º 1
0
 /**
  * Saves image to file.
  * 
  * @param string|null $file Path to save file. If not specified, image is saved at its original path.
  * @param int|null $quality Image quality: from 1 to 100; defaults to 100.
  * @return bool Whether file was saved successfully
  */
 public function save($file = null, $quality = null)
 {
     $config = wa('shop')->getConfig();
     if ($quality === null) {
         $quality = $config->getSaveQuality();
         if (!$quality) {
             $quality = 100;
         }
     }
     // check save_original option
     if ($config->getOption('image_save_original')) {
         // get original file name
         if (($i = strrpos($this->file, '.')) !== false) {
             $original_file = substr($this->file, 0, $i) . '.original' . substr($this->file, $i);
         } else {
             $original_file = $this->file . '.original';
         }
         // save original file if it not exists
         if (!file_exists($original_file)) {
             copy($this->file, $original_file);
         }
     }
     // save image
     return $this->image->save($file, $quality);
 }
Exemplo n.º 2
0
 public function save($file = null, $quality = null)
 {
     $config = wa('photos')->getConfig();
     if ($quality === null) {
         $quality = $config->getSaveQuality();
     }
     // check save_original option
     if ($config->getOption('save_original')) {
         // get original file name
         $original_file = photosPhoto::getOriginalPhotoPath($this->file);
         // save original file if it not exists
         if (!file_exists($original_file)) {
             copy($this->file, $original_file);
         }
     }
     // save image
     return $this->image->save($file, $quality);
 }