示例#1
0
 /**
  * @param string $file
  * @return bool|string
  */
 public function drawFrames(Image $file, RecognizeResult $recognizeResult)
 {
     $im = imagecreatefromstring($file->getFileContents());
     if (false === $im) {
         throw new RecognizeImException('Image type is unsupported, the data is not in a recognised ' . 'format, or the image is corrupt and cannot be loaded.');
     }
     $color = imagecolorallocate($im, 255, 255, 255);
     /** @var RecognizedImage $object */
     foreach ($recognizeResult->getObjects() as $object) {
         $location = $object->getLocation();
         $size = count($location);
         for ($i = 0; $i < $size; ++$i) {
             $p1 = $location[$i];
             $p2 = $location[($i + 1) % $size];
             imageline($im, $p1['x'], $p1['y'], $p2['x'], $p2['y'], $color);
         }
     }
     ob_start();
     imagejpeg($im);
     $img = ob_get_clean();
     imagedestroy($im);
     return $img;
 }
示例#2
0
 /**
  * Upload an image to images collection
  *
  * @param string $id
  * @param string $name
  * @param Image $data
  * @throws SoapApiException
  */
 public function imageInsert($id, $name, Image $data)
 {
     $result = new SoapRequestResult($this->soapClient->imageInsert($id, $name, base64_encode($data->getFileContents())));
     $this->checkRequestResultSuccess($result);
 }