/**
  * https://github.com/elgervb/imagemanipulation/issues/26
  */
 public function testTooLargeY()
 {
     $res = ImageGenerator::create(826, 1251, new Color('#999'));
     $thumbilizer = new Thumbalizer(new MaxPixelStrategy(250, 250));
     $thumb = $thumbilizer->create($res);
     $this->assertEquals(165, $thumb->getX(), 'Checking image width');
     $this->assertEquals(250, $thumb->getY(), 'Checking image height');
 }
 public function testCreate()
 {
     $width = 250;
     $height = 750;
     $color = 'ff00ff';
     $res = ImageGenerator::create($width, $height, new Color($color));
     $this->assertEquals($width, $res->getX());
     $this->assertEquals($height, $res->getY());
     $this->assertEquals($color, ColorUtil::getColorAt($res, Coordinate::create(0, 0))->getHexColor());
     $this->assertEquals($color, ColorUtil::getColorAt($res, Coordinate::create($width / 2, $height / 2))->getHexColor());
     $this->assertEquals($color, ColorUtil::getColorAt($res, Coordinate::create($width - 1, $height - 1))->getHexColor());
 }
 public function testGradient()
 {
     $width = 250;
     $height = 750;
     $startColor = 'ffffff';
     $endColor = '000000';
     $res = ImageGenerator::gradient($width, $height, 1, new Color($startColor), new Color($endColor));
     $this->assertEquals($width, $res->getWidth());
     $this->assertEquals($height, $res->getHeight());
     $this->assertEquals($startColor, ColorUtil::getColorAt($res, Coordinate::create(0, 0))->getHexColor());
     $this->assertEquals('7e7e7e', ColorUtil::getColorAt($res, Coordinate::create($width / 2, $height / 2))->getHexColor());
     $this->assertEquals($endColor, ColorUtil::getColorAt($res, Coordinate::create($width - 1, $height - 1))->getHexColor());
 }
Ejemplo n.º 4
0
<?php

use imagemanipulation\generation\ImageGenerator;
use imagemanipulation\ImageType;
use imagemanipulation\color\Color;
ImageGenerator::create(500, 200, new Color('#747474'))->render(ImageType::PNG, 80);
<?php

use imagemanipulation\generation\ImageGenerator;
use imagemanipulation\ImageType;
use imagemanipulation\color\Color;
ImageGenerator::gradient(500, 200, 0, new Color('#6EC5E3'), new Color('#BF2074'))->render(ImageType::PNG, 80);