Exemplo n.º 1
0
 public function testShouldSetAndGetFormat()
 {
     $resource = $this->getMockBuilder('Imanee\\ImageResource\\GDResource')->setMethods(['setFormat', 'getFormat'])->getMock();
     $resource->expects($this->once())->method('setFormat')->with('jpeg');
     $resource->expects($this->once())->method('getFormat')->will($this->returnValue('jpeg'));
     $this->model->setResource($resource);
     $this->model->setFormat('jpeg');
     $this->assertEquals('jpeg', $this->model->getFormat());
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function animate(array $frames, $delay = 20)
 {
     $gif = new \Imagick();
     $gif->setFormat('gif');
     foreach ($frames as $im) {
         if ($im instanceof Imanee) {
             $frame = $im->getResource()->getResource();
         } else {
             $frame = new \Imagick($im);
         }
         $frame->setImageDelay($delay);
         $gif->addImage($frame);
     }
     $imagickResource = new ImagickResource();
     $imagickResource->setResource($gif);
     $imanee = new Imanee();
     $imanee->setResource($imagickResource);
     $imanee->setFormat('gif');
     return $imanee;
 }
Exemplo n.º 3
0
 /**
  * Convenient method for generating text-only images
  *
  * @param string $text
  * @param Drawer $drawer
  * @param string $format
  * @param string $background
  * @return Imanee
  */
 public static function textGen($text, Drawer $drawer = null, $format = 'png', $background = 'transparent', ImageResourceInterface $resource = null)
 {
     $imanee = new Imanee(null, $resource);
     if ($drawer !== null) {
         $imanee->setDrawer($drawer);
     }
     $size = $imanee->resource->getTextGeometry($text, $imanee->getDrawer());
     $imanee->newImage($size['width'], $size['height'], $background);
     $imanee->setFormat($format);
     $imanee->placeText($text, Imanee::IM_POS_TOP_LEFT);
     return $imanee;
 }