コード例 #1
0
ファイル: Cache.php プロジェクト: Daegon/illuminage
 /**
  * Get the cache hash of an image
  *
  * @param Image $image
  *
  * @return string
  */
 public function getHashOf(Image $image)
 {
     $imagePath = $image->getOriginalImagePath();
     // Build the salt array
     $salts = $image->getSalts();
     $salts[] = $image->getQuality();
     $salts[] = md5($imagePath);
     $salts = serialize($salts);
     // Get image extension
     $extension = pathinfo($imagePath, PATHINFO_EXTENSION);
     return md5($salts) . '.' . $extension;
 }
コード例 #2
0
 /**
  * Process an Image
  *
  * @param Image $image
  *
  * @return ImagineInterface
  */
 public function process(Image $image)
 {
     $processors = $image->getSalts();
     $image = $this->imagine->open($image->getOriginalImagePath());
     // Apply each method one after the other
     foreach ($processors as $method => $arguments) {
         if (empty($arguments) or isset($arguments[0])) {
             $image = $this->executeMethod($image, $method, $arguments);
         } else {
             foreach ($arguments as $submethod => $arguments) {
                 $this->executeSubmethod($image, $method, $submethod, $arguments);
             }
         }
     }
     return $image;
 }