/** * @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()); }
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); }
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); }
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); }
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); }
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); }
/** * @expectedException \JBZoo\Image\Exception */ public function testTextUndefinedFontFile() { $original = Helper::getOrig('butterfly.jpg'); $img = new Image($original); $img->addFilter('text', 'Nice Butterfly', 'Undefined'); }
public function testPHP53_getimagesizefromstring() { try { $img = new Image(); $img->loadString('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='); } catch (Exception $e) { isTrue(strpos(PHP_VERSION, '5.3') === 0); } }
public function testGetWidthAndHeight() { $original = Helper::getOrig('butterfly.png'); $img = new Image($original); is(640, $img->getWidth()); is(478, $img->getHeight()); }
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; }
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); }