Example #1
0
 /**
  * Replace current image with $image
  *
  * @param image $image
  *
  * @return image
  */
 public function replace(Super_Image $image)
 {
     $this->imagick = $image->getImagick();
     $this->update();
     return $this;
 }
Example #2
0
 private static function createPreview($image, $previewWidth, $previewHeight, $fill = '#ffffff', $cut = false)
 {
     $previewName = self::getPreviewName($image, $previewWidth, $previewHeight, $fill, $cut);
     $img = Image::factory($image);
     if ($cut) {
         $ratio = $img->width / $img->height;
         $original_ratio = $previewWidth / $previewHeight;
         $crop_width = $img->width;
         $crop_height = $img->height;
         if ($ratio > $original_ratio) {
             $crop_width = round($original_ratio * $crop_height);
         } else {
             $crop_height = round($crop_width / $original_ratio);
         }
         $img->crop($crop_width, $crop_height);
         $img->resize($previewWidth, $previewHeight, Image::NONE);
         $img->save($previewName);
     } else {
         $img->resize($previewWidth, $previewHeight)->save($previewName);
         $imgSuper = Super_Image::create($previewWidth, $previewHeight)->fill($fill)->combineCentered(Super_Image::load($previewName))->save($previewName);
     }
 }