示例#1
0
 /**
  * @param $file
  * @return array
  */
 public function uploadScreenShot3($file)
 {
     $name = Str::random() . '.' . strtolower($file->ext);
     $image = new Image($file->image);
     $image->saveAs(PATH_PUBLIC . '/images/' . $name, 100);
     return array('UploadScreenShot3Result' => $image->getUrl());
 }
示例#2
0
 public function testAutoOrient()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.jpg');
     $actual = Helper::getActual(__FUNCTION__ . '.jpg');
     $original = Helper::getOrig('butterfly.jpg');
     $img = new Image();
     $img->loadFile($original)->autoOrient()->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }
示例#3
0
 public function testIssue8()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.png');
     $base = Helper::getOrig('issue-8/original.png');
     $img = new Image($base);
     if ($img->getHeight() != $img->getWidth()) {
         if ($img->getWidth() < 175) {
             $img->fitToWidth($img->getWidth());
         } else {
             $img->fitToWidth(175);
         }
     } else {
         $img->bestFit(175, 175);
     }
     $img->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }
示例#4
0
 public function testBorderColorSize()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.png');
     $original = Helper::getOrig('butterfly.jpg');
     $img = new Image();
     $img->loadFile($original)->addFilter('border', array('color' => 'ff0', 'size' => '5'))->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }
示例#5
0
 public function testWatermark()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.png');
     $original = Helper::getOrig('butterfly.jpg');
     $overlay = Helper::getOrig('overlay.png');
     $img = new Image();
     $img->loadFile($original)->overlay($overlay)->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }
示例#6
0
 public function testFlipRorateRevert275White()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.png');
     $original = Helper::getOrig('butterfly.jpg');
     $img = new Image();
     $img->loadFile($original)->addFilter('rotate', -275, array(255, 255, 255, 127))->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }
示例#7
0
文件: TextTest.php 项目: JBZoo/Image
 /**
  * @expectedException \JBZoo\Image\Exception
  */
 public function testTextUndefinedFontFile()
 {
     $original = Helper::getOrig('butterfly.jpg');
     $img = new Image($original);
     $img->addFilter('text', 'Nice Butterfly', 'Undefined');
 }
示例#8
0
文件: ImageTest.php 项目: Ruyan/Image
 public function testPHP53_getimagesizefromstring()
 {
     try {
         $img = new Image();
         $img->loadString('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
     } catch (Exception $e) {
         isTrue(strpos(PHP_VERSION, '5.3') === 0);
     }
 }
示例#9
0
文件: ImageTest.php 项目: JBZoo/Image
 public function testGetWidthAndHeight()
 {
     $original = Helper::getOrig('butterfly.png');
     $img = new Image($original);
     is(640, $img->getWidth());
     is(478, $img->getHeight());
 }
示例#10
0
 public function uploadImage($fieldName = "upload", $folder = "upload/", $width = null, $height = null)
 {
     $output = $this->upload($fieldName, $folder);
     $path = $output["url"];
     $img = new Image($path);
     if ($width == null && $height == null) {
         return $output;
     } else {
         if ($width == null) {
             $img->fitToHeight($height);
         } else {
             if ($height == null) {
                 $img->fitToWidth($width);
             } else {
                 $img = $img->resize($width, $height);
             }
         }
     }
     $img->save();
     return $output;
 }
示例#11
0
 public function testBestFitNoChange()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.png');
     $original = Helper::getOrig('butterfly.jpg');
     $img = new Image();
     $img->loadFile($original)->bestFit(10000, 10000)->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }