图片滤镜（AI Lab）.

@param mixed  $image      仅支持 JPG、PNG 类型图片，尺寸长宽不超过 1080，返回格式 JPG
@param string $session_id
@param int    $filter     滤镜效果编码 1-65

@throws TencentAIException

@return array
326681
public function aiLabFilter($image, string $session_id, int $filter)
    {
        $image = self::encode($image);

        return Request::exec(self::AILAB_FILTER, compact('filter', 'image', 'session_id'));
    }
371580
public static xen_bluecatvpx_image[] get_filtered(nitro_service service, String filter) throws Exception
	{
		xen_bluecatvpx_image obj = new xen_bluecatvpx_image();
		options option = new options();
		option.set_filter(filter);
		xen_bluecatvpx_image[] response = (xen_bluecatvpx_image[]) obj.getfiltered(service, option);
		return response;
	}
668112
public static ns_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception
	{
		ns_image obj = new ns_image();
		options option = new options();
		option.set_filter(filter);
		ns_image[] response = (ns_image[]) obj.getfiltered(service, option);
		return response;
	}
522598
public function renderMultiImage ($model, $attribute)
    {
        /**
         * @var $srcTmp like this: src1,src2...srcxxx
         */
        $srcTmp = $model->$attribute;
        $items = [];
        if ($srcTmp) {
            is_string($srcTmp) && $srcTmp = explode(Yii::$app->params['webuploader']['delimiter'], $srcTmp);
            $inputName = Html::getInputName($model, $attribute);
            foreach ($srcTmp as $k => $v) {
                $dv = $this->_validateUrl($v) ? $v : Yii::$app->params['domain'] . $v;
                $src = $v ? $dv : Yii::$app->params['webuploader']['baseConfig']['defaultImage'];
                $eles = [];
                $eles[] = Html::img($src, ['class' => 'img-responsive img-thumbnail cus-img']);
                $eles[] = Html::hiddenInput($inputName . "[]", $v);
                $eles[] = Html::tag('em', 'x', ['class' => 'close delMultiImage', 'title' => '删除这张图片']);
                $items[] = Html::tag('div', implode("\n", $eles), ['class' => 'multi-item']);
            }
        } 

        return Html::tag('div', implode("\n", $items), ['class' => 'input-group multi-img-details']);
    }
449453
public function addImageWater($waterImage, $position, $alpha=80) {

        $sizeDst = $this->getImageSize($this->imgSrc);
        if ( !$position ) {
            $this->position = self::POS_RANDOM;
        } else {
            $this->position = $position;
        }

        //创建目标画布
        $this->imgDst = $this->creatImageTrueColor($sizeDst[0], $sizeDst[1], $this->extension);

        //将图像载入画布
        imagecopyresampled($this->imgDst, $this->imgSrc, 0, 0, 0, 0, $sizeDst[0], $sizeDst[1], $sizeDst[0], $sizeDst[1]);

        $imageWater = &$this->getImageSource($waterImage);
        $waterSize = $this->getImageSize($imageWater);	//获取水印大小
        $waterPosition = $this->getWaterPos($sizeDst, $waterSize);	//获取水印位置
        if ( $this->imgDst && $imageWater ) {
            imagecopymerge(
                $this->imgDst,
                $imageWater,
                $waterPosition[0],
                $waterPosition[1],
                0, 0,
                $waterSize[0],
                $waterSize[1], $alpha);
        }
        return $this;

    }
874436
public function read($session_id)
	{
		if ($this->files->exists($path = $this->path . DS . $session_id))
		{
			return $this->files->get($path);
		}

		return '';
	}
681970
public static xen_image[] get_filtered(nitro_service service, String filter) throws Exception
	{
		xen_image obj = new xen_image();
		options option = new options();
		option.set_filter(filter);
		xen_image[] response = (xen_image[]) obj.getfiltered(service, option);
		return response;
	}
565461
public function check($value, $rm = true, $id = '') {
        $key = md5('raphp.Caption_image_pick_KEY') . $id;
        // 验证码不能为空
        $secode = request()->session()->get($key);
        if (empty($value) || empty($secode)) {
            return false;
        }
        // session 过期
        if (time() - $secode[ 'verify_time' ] > $this->expire) {
            request()->session()->del($key);
            return false;
        }
        $data = explode(' ', $value);
        $sign = $secode[ 'sign' ];
        $test = [];
        $r = [];
        for ($i = 0; $i < count($data); $i += 2) {
            $x = (int)EncryptUtil::decrypt($data[ $i ], $sign);
            $y = (int)EncryptUtil::decrypt($data[ $i + 1 ], $sign);
            $x = $x / 10000000000000000;
            $y = $y / 10000000000000000;
            $test[] = ['x' => $x, 'y' => $y];
            $sec = $secode[ (int)($i / 2) ];
            $result = false;
            if ($x > $sec[ 'x' ] && $x < $sec[ 'x1' ] && $y > $sec[ 'y1' ] && $y < $sec[ 'y' ]) {
                $result = true;
            }
            if (!$result) {
                return false;
            }
            $r[] = $result;
        }
        if ($rm) {
            request()->session()->del($key);
        }
        return true;
        //      return ['secode'=>$secode,'code'=>$test,'result'=>$r];
    }
534123
public static aaasession[] get_filtered(nitro_service service, String filter) throws Exception{
		aaasession obj = new aaasession();
		options option = new options();
		option.set_filter(filter);
		aaasession[] response = (aaasession[]) obj.getfiltered(service, option);
		return response;
	}
783226
public function createSessionID()
    {
        // 时间+自增，md5 id+时间各自的一半，重复概率很小了吧
        $id = AtomicManager::add('session');
        $time = microtime();
        return substr(md5($id), 0, 16) . substr(md5($time), 0, 16);
    }
943247
protected function _add_data_srcset_to_content_image( $image, $image_id ) {
		return preg_replace_callback(
			'@(<img decoding="async"[^>]*?)srcset="([^"]+?)"([^>]*?>)@m',
			function( $matches ) use ( $image_id ) {
				return sprintf(
					'%s srcset="" data-srcset="%s" %s',
					$matches[1],
					$matches[2],
					$matches[3]
				);
			},
			$image
		);
	}
72321
public function applyFilter(Image $image)
    {
        return $image->resize(300, null, function($constraint) {
            $constraint->aspectRatio();
        })->encode('jpg', 40);
    }
1321554
public function getImagesWithQuery(int $id, array $query): array
    {
        /* @var TheTVDbAPILanguageFallback $parent */
        $parent  = $this->parent;
        $closure = $this->getClosureForImagesWithQuery($id, ['query' => $query]);

        return $parent->getGenerator()->create($closure, Image::class, $this->parent->getAcceptedLanguages(), true);
    }
1235471
protected function getSessionFile(/*# string */ $session_id)/*# : string */
    {
        // path
        $res = [$this->path_prefix];

        // scatter evenly
        $md5 = md5($session_id);
        $res[] = $md5[0];
        $res[] = $md5[1];

        // append session id
        $res[] = $session_id;

        return join('/', $res);
    }
862075
public function porn($image, string $image_url = null)
    {
        if ($image_url) {
            return self::image(self::PORN, $image_url, true);
        }

        return self::image(self::PORN, $image);
    }
962290
protected RenderedImage doFilter(BufferedImage pImage, ServletRequest pRequest, ImageServletResponse pResponse) {
        // Get angle
        double ang = getAngle(pRequest);

        // Get bounds
        Rectangle2D rect = getBounds(pRequest, pImage, ang);
        int width = (int) rect.getWidth();
        int height = (int) rect.getHeight();

        // Create result image
        BufferedImage res = ImageUtil.createTransparent(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = res.createGraphics();

        // Get background color and clear
        String str = pRequest.getParameter(PARAM_BGCOLOR);
        if (!StringUtil.isEmpty(str)) {
            Color bgcolor = StringUtil.toColor(str);
            g.setBackground(bgcolor);
            g.clearRect(0, 0, width, height);
        }

        // Set mHints (why do I always get jagged edgdes?)
        RenderingHints hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
        hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC));

        g.setRenderingHints(hints);

        // Rotate around center
        AffineTransform at = AffineTransform
                .getRotateInstance(ang, width / 2.0, height / 2.0);

        // Move to center
        at.translate(width / 2.0 - pImage.getWidth() / 2.0,
                     height / 2.0 - pImage.getHeight() / 2.0);

        // Draw it, centered
        g.drawImage(pImage, at, null);

        return res;
    }
393110
public function session($session_id)
	{
		$query = $this->connection->getQuery()
			->select('*')
			->from('#__session')
			->group('userid')
			->group('client_id')
			->order('time', 'desc');

		$this->connection->setQuery($query->toString());
		return $this->connection->loadObject();
	}