Пример #1
0
 /**
  * Height + width is LESS than max
  *
  * Resize base on one of both
  */
 public function testLandscapeGreaterHeight()
 {
     // "landscape"
     $width = 15;
     $height = 30;
     $maxWidth = 15;
     $maxHeight = 10;
     $resize = new ImageResize();
     list($newWidth, $newHeight) = $resize->getCalculatedSize($width, $height, $maxWidth, $maxHeight);
     $this->assertEquals(5, $newWidth);
     $this->assertEquals(10, $newHeight);
 }
Пример #2
0
 /**
  *
  * @param  string $imageData
  * @param  number $maxWidth
  * @param  number $maxHeight
  * @return array
  */
 protected function calcImageSize($imageData, $maxWidth, $maxHeight)
 {
     $pdf = $this->getPdf();
     list($width, $height) = getimagesizefromstring($imageData);
     $width = $pdf->pixelsToUnits($width);
     $height = $pdf->pixelsToUnits($height);
     list($newWidth, $newHeight) = ImageResize::getCalculatedSize($width, $height, $maxWidth, $maxHeight);
     return [$newWidth, $newHeight];
 }