/**
  * Test resize cropping edge case.
  *
  * @test
  * @return void
  */
 public function it_should_be_able_to_resize_and_crop_an_edge_case()
 {
     $uploadedFile = $this->buildUploadedFile();
     $originalSize = new Box(1000, 653);
     $expectedResize = new Box(440, 287.32);
     $expectedCropPoint = new Point(0, 21.66);
     $expectedCropBox = new Box(440, 244);
     $image = $this->buildMockImage($originalSize, $expectedResize, $expectedCropPoint, $expectedCropBox);
     $imageProcessor = $this->buildMockImageProcessor($image);
     $resizer = new Resizer($imageProcessor);
     $style = $this->buildMockStyleObject('thumbnail', '440x244#');
     $file = $resizer->resize($uploadedFile, $style);
 }
Exemple #2
0
 /**
  * Return a resizer object instance.
  *
  * @param string $type
  * @return \Codesleeve\Stapler\File\Image\Resizer
  */
 public static function getResizerInstance($type)
 {
     $imagineInstance = static::getImagineInstance($type);
     if (static::$resizer === null) {
         static::$resizer = new Resizer($imagineInstance);
     } else {
         static::$resizer->setImagine($imagineInstance);
     }
     return static::$resizer;
 }
 /**
  * Process the queuedForWrite que.
  */
 protected function flushWrites()
 {
     foreach ($this->queuedForWrite as $style) {
         if ($style->dimensions && $this->uploadedFile->isImage()) {
             $file = $this->resizer->resize($this->uploadedFile, $style);
         } else {
             $file = $this->uploadedFile->getRealPath();
         }
         $filePath = $this->path($style->name);
         $this->move($file, $filePath);
     }
     $this->queuedForWrite = [];
 }