名片识别接口

@param string $image - 图像数据，base64编码，要求base64编码后大小不超过4M，最短边至少15px，最长边最大4096px,支持jpg/png/bmp格式
@param array $options - 可选参数对象，key: value都为string类型
@description options列表:
@return array
435158
public function businessCard($image, $options=array()){

        $data = array();
        
        $data['image'] = base64_encode($image);

        $data = array_merge($data, $options);

        return $this->request($this->businessCardUrl, $data);
    }
597496
public static function getImageThumbTag( $image, $options = [] ) {

		// Use Image from DB
		if( isset( $image ) ) {

			$thumbUrl = $image->getThumbUrl();

			if( isset( $options[ 'class' ] ) ) {

				$class = $options[ 'class' ];

				return "<img class='$class' src='$thumbUrl'>";
			}
			else {

				return "<img src='$thumbUrl'>";
			}
		}
		else {

			// Use Image from web root directory
			if( isset( $options[ 'image' ] ) ) {

				$images = Yii::getAlias( '@images' );
				$img	= $options[ 'image' ];

				if( isset( $options[ 'class' ] ) ) {

					$class	= $options[ 'class' ];

					return "<img class='$class' src='$images/$img'>";
				}
				else {

					return "<img src='$images/$img'>";
				}
			}
			// Use icon
			else if( isset( $options[ 'icon' ] ) ) {

				$icon = $options[ 'icon' ];

				return "<span class='$icon'></span>";
			}
		}
	}
1298031
private function getPathsForUrl($image)
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        $runtimeImagerPath = Craft::$app->getPath()->getRuntimePath().'/imager/';
        $convertedImageStr = StringHelper::toAscii(urldecode($image));
        $this->transformPath = ImagerHelpers::getTransformPathForUrl($convertedImageStr);

        $urlParts = parse_url($convertedImageStr);
        $pathParts = pathinfo($urlParts['path']);
        $queryString = $config->getSetting('useRemoteUrlQueryString') ? ($urlParts['query'] ?? '') : '';

        $this->path = FileHelper::normalizePath($runtimeImagerPath.$this->transformPath.'/');
        $this->url = $image;
        $this->basename = str_replace(' ', '-', $pathParts['filename']).($queryString !== '' ? '_'.md5($queryString) : '');
        $this->extension = $pathParts['extension'] ?? '';
        $this->filename = FileHelper::sanitizeFilename($this->basename.'.'.$this->extension);

        try {
            FileHelper::createDirectory($this->path);
        } catch (Exception $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }
    }
996305
public function imagePath($image)
    {
        if (!$image) {
            return '';
        }

        $parts = explode(';', $image);
        $fileId = $parts[0];

        // deliver original file
        $src = $this->router->generate('frontendmedia_inline', ['fileId' => $fileId], UrlGeneratorInterface::ABSOLUTE_PATH);

        return $src;
    }
722958
public function load(ImageInterface $image, array $options = [])
    {
        $options = $this->sanitizeOptions($options);

        return 'x' === $options['axis'] ? $image->flipHorizontally() : $image->flipVertically();
    }
227668
public static function image($image, $options = [])
	{
		$static = new static;

		$static->image = $image;
		$static->options = $options;
		$static->intervention = new ImageManager(['driver' => 'gd']);

		$static->normalizeNames();

		return $static;
	}
699952
public function image($dir, $image, $width = null, $height = null, array $options = [], array $attributes = [])
    {
        $attributes = array_replace_recursive($this->attributes, $attributes);
        $options    = array_replace_recursive($this->options, $options);

        $path = config('laravelimage.routePath') . '/' . $dir . $image . '?' . http_build_query($options, '', '&');

        if ( ! empty((int) $width)) {
            $path .= '&w=' . (int) $width;
        }

        if ( ! empty((int) $height)) {
            $path .= '&h=' . (int) $height;
        }

        return '<img src="' . asset($path) . '" ' . $this->buildAttributes($attributes) . ' />';
    }
1143681
private function ordered( $image ) {
        // Localize vars
        $width  = $image->getWidth();
        $height = $image->getHeight();
        $old    = $image->getCore();

        $new = imagecreatetruecolor( $width, $height );

        $thresholdMap = array(
            array( 15, 135, 45, 165 ),
            array( 195, 75, 225, 105 ),
            array( 60, 180, 30, 150 ),
            array( 240, 120, 210, 90 )
        );

        for ( $y = 0; $y < $height; $y += 1 ) {
            for ( $x = 0; $x < $width; $x += 1 ) {

                $color = imagecolorat( $old, $x, $y );
                $r     = ( $color >> 16 ) & 0xFF;
                $g     = ( $color >> 8 ) & 0xFF;
                $b     = $color & 0xFF;

                $gray = round( $r * 0.3 + $g * 0.59 + $b * 0.11 );

                $threshold = $thresholdMap[ $x % 4 ][ $y % 4 ];
                $oldPixel  = ( $gray + $threshold ) / 2;
                if ( $oldPixel <= 127 ) { // Determine if black or white. Also has the benefit of clipping excess value
                    $newPixel = 0;
                } else {
                    $newPixel = 255;
                }

                // Current pixel
                imagesetpixel( $new, $x, $y,
                    imagecolorallocate( $new,
                        $newPixel,
                        $newPixel,
                        $newPixel
                    )
                );

            }
        }

        imagedestroy( $old ); // Free resource
        // Create new image with updated core
        return new Image(
            $new,
            $image->getImageFile(),
            $width,
            $height,
            $image->getType()
        );
    }
714652
public function execute($image)
    {
        $source = $this->argument(0)->required()->value();
        $position = $this->argument(1)->type('string')->value();
        $x = $this->argument(2)->type('digit')->value(0);
        $y = $this->argument(3)->type('digit')->value(0);

        // build watermark
        $watermark = $image->getDriver()->init($source);

        // define insertion point
        $image_size = $image->getSize()->align($position, $x, $y);
        $watermark_size = $watermark->getSize()->align($position);
        $target = $image_size->relativePosition($watermark_size);

        // insert image at position
        imagealphablending($image->getCore(), true);
        return imagecopy($image->getCore(), $watermark->getCore(), $target->x, $target->y, 0, 0, $watermark_size->width, $watermark_size->height);
    }
211993
public function execute($image)
    {
        $colors = [];

        $size = $image->getSize();

        for ($x=0; $x <= ($size->width-1); $x++) {
            for ($y=0; $y <= ($size->height-1); $y++) {
                $colors[] = $image->pickColor($x, $y, 'array');
            }
        }

        $this->setOutput(md5(serialize($colors)));

        return true;
    }
3114
public static function getImageInfo($image, array $config = null)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $img = new static($image['value'], $finfo, $config);

        $curl = $img->getConnection();
        curl_exec($curl);
        curl_close($curl);

        $info = $img->getInfo();

        finfo_close($finfo);

        return $info;
    }
789461
public function logoDeleteByImage($image, $options=array()){

        $data = array();
        
        $data['image'] = base64_encode($image);

        $data = array_merge($data, $options);

        return $this->request($this->logoDeleteUrl, $data);
    }
1288195
public function saveToString($image, $options)
    {
        $outputMethod = $this->getOutputMethod($options);
        ob_start();
        $outputMethod($image);
        $string = ob_get_contents();
        ob_end_clean();
        return $string;
    }
79416
public function getInfo($image)
    {
        if (DriverInterface::IMAGE_STORAGE_STRING == $this->getImageStorage($image)) {
            $image = 'data://application/octet-stream;base64,'  . base64_encode($image);
        }
        return getimagesize($image);
    }
1372833
public function passport($image, $options=array()){

        $data = array();
        
        $data['image'] = base64_encode($image);

        $data = array_merge($data, $options);

        return $this->request($this->passportUrl, $data);
    }
886644
public function execute($image)
    {
        $red = $this->argument(0)->between(-100, 100)->required()->value();
        $green = $this->argument(1)->between(-100, 100)->required()->value();
        $blue = $this->argument(2)->between(-100, 100)->required()->value();

        // normalize colorize levels
        $red = round($red * 2.55);
        $green = round($green * 2.55);
        $blue = round($blue * 2.55);

        // apply filter
        return imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $red, $green, $blue);
    }
828777
public function tableRecognition($image, $options=array(), $timeout=10000){
        $result = $this->tableRecognitionAsync($image);
        if(isset($result['error_code'])){
            return $result;
        }
        $requestId = $result['result'][0]['request_id'];
        $count = ceil($timeout / 1000);
        for($i=0; $i<$count; $i++){
            $result = $this->getTableRecognitionResult($requestId, $options);
            // 完成
            if($result['result']['ret_code'] == 3){ 
                break;
            }
            sleep(1);
        }
        return $result;
    }