Пример #1
0
 protected function _scaleAndStoreForTemplate($sourceData, $imageType, $id, $template, $overwrite)
 {
     $file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
     $scaleParams = $this->getTemplateParameters($template);
     // clone this scaler, since scaling parameters are stored as class properties
     $clonedScaler = clone $this;
     $scaledImageDataArray = $clonedScaler->scale($sourceData, $scaleParams, $imageType);
     $scaledFilePath = $this->getScaledPath($id, $template);
     if ($overwrite || !$file->exists($scaledFilePath)) {
         $file->store($scaledFilePath, $scaledImageDataArray['resource'], true, false);
     }
 }
Пример #2
0
 protected function _scaleDatabaseImage(Garp_Db_Table_Row $record, Garp_Image_File $file, Garp_Image_Scaler $scaler, $template, $overwrite)
 {
     $id = $record->id;
     $filename = $record->filename;
     if (!$file->exists($filename)) {
         Garp_Cli::errorOut('Warning: ' . $filename . ' is in the database, but not on disk!');
         return;
     }
     if ($file->exists($scaler->getScaledPath($id, $template, true)) && !$overwrite) {
         Garp_Cli::lineOut($template . '/' . $id . ' already exists, skipping');
         return;
     }
     try {
         $scaler->scaleAndStore($filename, $id, $template, $overwrite);
         Garp_Cli::lineOut('Scaled image #' . $id . ': ' . $filename);
         return true;
     } catch (Exception $e) {
         Garp_Cli::errorOut("Error scaling " . $filename . " (#" . $id . "): " . $e->getMessage());
     }
 }