Exemplo n.º 1
0
 /**
  * @covers MemePuush\Image::setOutputFormat
  * @covers MemePuush\Image::getOutputFormat
  * @covers MemePuush\Image::getApiKey
  */
 public function testSetOutputFormat()
 {
     $this->object->setOutputFormat('puush', '2347834');
     $this->assertEquals('puush', $this->object->getOutputFormat());
     $this->assertEquals('2347834', $this->object->getApiKey());
 }
Exemplo n.º 2
0
 //source image to overlay
 $img = isset($_GET['img']) ? $_GET['img'] : '';
 if ($output == 'puush' && !$apiKey) {
     throw new \Exception('Puu.sh api key must be provided');
 }
 if (!$t1 && !$t2) {
     throw new \Exception('No caption provided');
 }
 if (!$img) {
     throw new \Exception('No image url provided');
 }
 $image = new Image($img);
 //if the image doesn't exist, cannot continue
 //if( !$image )
 //    throw new \Exception( 'Could not load image: ' . $img );
 $image->setOutputFormat($output, $apiKey);
 $image->setTopCaption($t1);
 $image->setBottomCaption($t2);
 $outputContent = $image->output();
 switch ($output) {
     case 'screen':
         header('Content-type: image/jpg');
         echo file_get_contents($outputContent);
         break;
     case 'file':
         echo $outputContent;
         break;
     case 'puush':
         echo json_encode(array('url' => $outputContent));
         break;
 }