コード例 #1
0
 /**
  * Manipulates image according to image format definitons
  *
  * @param string $sourcePath
  * @param string $destPathWithFormat
  * @param string $format
  */
 public function transform($sourcePath, $destPathWithFormat, $format)
 {
     $confPerso = isset($this->imageFormatDefinition[$format]) ? $this->imageFormatDefinition[$format] : array();
     $confDefault = isset($this->defaultConfiguration[$format]) ? $this->defaultConfiguration[$format] : array();
     $confFallback = $this->defaultConfiguration['fallback'];
     if ($format === 'original') {
         $dir = dirname($destPathWithFormat);
         if (!file_exists($dir)) {
             mkdir($dir, 0777, true);
         }
         copy($sourcePath, $destPathWithFormat);
         return;
     }
     $dim = array_merge(array('format_name' => $format), $confFallback, $confDefault ? $confDefault : array(), $confPerso ? $confPerso : array());
     if (strpos($dim['bg_color'], '#') === 0) {
         $dim['bg_color'] = substr($dim['bg_color'], 1);
     }
     ResizeManager::resize($sourcePath, $destPathWithFormat, $dim);
 }
コード例 #2
0
 /**
  * Manipulates image according to image format definitons
  *
  * @param string $sourcePath              The source image path
  * @param string $fileDestinationAbsolute The destination path ({-img-format-} placeholder will be updated if neeeded)
  * @param string $format                  The desired image format
  */
 private function imageManipulation($sourcePath, $fileDestinationAbsolute, $format)
 {
     $destPathWithFormat = $this->transformPathWithFormat($fileDestinationAbsolute, $format);
     $resizeManager = new ResizeManager($this->imageFormatDefinition);
     $resizeManager->transform($sourcePath, $destPathWithFormat, $format);
 }