public function testThumbPng()
 {
     $img = $this->getOriginalImage(ImageType::PNG);
     $res = ImageBuilder::create($img)->thumbMax(300, 200)->toResource();
     $this->assertEquals(200, $res->getX());
     $this->assertEquals(200, $res->getY());
 }
 public function testGifRedImageBuilder()
 {
     $original = $this->getOriginalImage(ImageType::GIF);
     $res = ImageBuilder::create($original)->duotone(255, 0, 0)->toResource();
     $this->assertColorQ1($res, 'ff0000');
     $this->assertColorQ2($res, 'ffff00');
     $this->assertColorQ3($res, 'ff00ff');
     $this->assertColorQ4($res, 'ffffff');
 }
 public function testPngOverlayGif()
 {
     $builder = new ImageBuilder($this->getOriginalImage(ImageType::PNG));
     $builder->overlay(__DIR__ . '/img/vignette.gif', 10);
     $res = $builder->toResource();
     $this->assertColorQ1($res, 'ea0504');
     $this->assertColorQ2($res, '05ea03');
     $this->assertColorQ3($res, '0504e9');
     $this->assertColorQ4($res, 'eaeae9');
 }
예제 #4
0
 public function vignette(\SplFileInfo $img)
 {
     return ImageBuilder::create($img)->vignette();
 }
예제 #5
0
/**
 * Includes and class loading
 */
include __DIR__ . '/../vendor/composer/ClassLoader.php';
use imagemanipulation\color\Color;
use imagemanipulation\ImageBuilder;
use imagemanipulation\generation\ImageGenerator;
$loader = new \Composer\Autoload\ClassLoader();
$loader->add('imagemanipulation', __DIR__ . '/..');
// activate the autoloader
$loader->register();
$loader->setUseIncludePath(true);
/**
 * https://github.com/elgervb/imagemanipulation/issues/23
 */
ImageBuilder::create(new \SplFileInfo(__DIR__ . '/sample.png'))->semiGrayscale(60)->render();
/*
 * Test Overlay
 */
// $builder = new ImageBuilder(new \SplFileInfo(__DIR__ . '/sample.png'));
// $builder->overlay(__DIR__ . '/../imagemanipulation/overlay/img/vignette.png', 90, 0, 0, true);
// $builder->save(new \SplFileInfo('\tmp\sample_png.png'));
// $builder = new ImageBuilder(new \SplFileInfo(__DIR__ . '/sample.png'));
// $builder->overlay(__DIR__ . '/../imagemanipulation/overlay/img/vignette.jpg', 50, 0, 0, true);
// $builder->save(new \SplFileInfo('\tmp\sample_jpg.png'));
// ImageBuilder::create('UglyDog.png')
//     ->contrast(10)
//     ->truecolor('fff', '00B0BA')
//     ->save(new \SplFileInfo('/tmp/result'.time().'.png'), true);
// echo 'done!';
/*// Test Rounded corners
 public function testMaxGif()
 {
     $img = $this->getOriginalImage(ImageType::GIF);
     $builder = ImageBuilder::create($img)->thumbCentered(200, 100);
     $res = $builder->thumbMax(100, 100)->toResource();
     $this->assertEquals($res->getX(), 100);
     $this->assertEquals($res->getY(), 50);
 }
예제 #7
0
 public function square(SplFileInfo $image, array $options = null)
 {
     // TODO cast to int workaround for https://github.com/elgervb/imagemanipulation/issues/25
     $width = (int) Options::option($options, 'width', '250');
     return ImageBuilder::create($image)->thumbSquare($width);
 }
예제 #8
0
<?php

use imagemanipulation\ImageBuilder;
require_once '../vendor/autoload.php';
$path = $_SERVER["REQUEST_URI"];
$paths = explode("/", $path);
$method = str_replace('.png', '', $paths[1]);
$b = ImageBuilder::create(__DIR__ . '/uglydog.png');
if (preg_match('/\\.(?:png|jpg|jpeg|gif)$/', $path)) {
    if ($path == "/uglydog.png") {
        return false;
        // serve the requested resource as-is
    }
    call_user_func_array(array($b, $method), array_slice($paths, 2));
    //->render();
}
echo '<img src="/uglydog.png" />';
echo '<img src="/' . $method . '.png" />';
예제 #9
0
 /**
  * Store the image in the static cache
  * 
  * @param ImageBuilder $builder
  * @param string $filter
  * @param string $options
  * @param \SplFileInfo $image
  */
 private function cacheImage(ImageBuilder $builder, $filter, $options, \SplFileInfo $image)
 {
     $cache = Context::get()->basePath('img');
     $filterDir = $cache . DIRECTORY_SEPARATOR . $filter;
     if (!is_dir($filterDir)) {
         mkdir($filterDir, 0777, true);
     }
     if ($options) {
         $filterOptionsDir = $filterDir . DIRECTORY_SEPARATOR . $options;
         if (!is_dir($filterOptionsDir)) {
             mkdir($filterOptionsDir, 0777);
         }
     } else {
         $filterOptionsDir = $filterDir;
     }
     $builder->save(new \SplFileInfo($filterOptionsDir . DIRECTORY_SEPARATOR . $image->getFilename()));
 }
예제 #10
0
 public static function blueish(ImageBuilder $builder)
 {
     $builder->colorize('#222b6d', 60)->colorize('#f7daae', 110)->gammaCorrection(1.2, 1.0);
 }
예제 #11
0
<?php

use imagemanipulation\ImageBuilder;
$ib = new ImageBuilder(new \SplFileInfo(__DIR__ . DIRECTORY_SEPARATOR . 'uglydog.png'));
$ib->contrast(10)->greyscale()->render(70);