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()); }
/** * {@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; }
/** * 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; }