@param int $width
@param int $height
@param int $ttl

@return \ManaPHP\Http\ResponseInterface
13492
public function generate($width = 100, $height = 30, $ttl = 300)
    {
        $code = '';
        $charsetCount = strlen($this->_charset);
        for ($i = 0; $i < $this->_length; $i++) {
            $code .= $this->_charset[mt_rand() % $charsetCount];
        }

        if (class_exists('Imagick')) {
            $response = $this->_generateByImagic($code, $width, $height);
        } elseif (function_exists('gd_info')) {
            $response = $this->_generateByGd($code, $width, $height);
        } else {
            throw new ExtensionNotInstalledException('`captcha` service is not support, please install `gd` or `imagic` extension first');
        }

        $captchaData = ['code' => $code, 'created_time' => time(), 'ttl' => $ttl];
        $this->session->set($this->_sessionVar, $captchaData);
        return $response;
    }
933042
public function handle($path, $width, $height, $action)
    {
        $file = $this->filesystem->getFile($path);

        return $this->urlGenerator->generate(
            'thumb',
            [
                'width'  => $width,
                'height' => $height,
                'action' => $action[0], // first char
                'file'   => $file->getPath(),
            ]
        );
    }
1181232
protected function getTargetDimensions($width, $height, $originalImagePath)
    {
        $originalDimensions = [$width, $height];

        try {
            $dimensions = getimagesize($originalImagePath);
            if (!$dimensions) {
                return $originalDimensions;
            }

            if ($dimensions[0] > $width || $dimensions[1] > $height) {
                return $originalDimensions;
            }

            return $dimensions;
        }
        catch (Exception $ex) {
            return $originalDimensions;
        }
    }
1277957
public function build($width, $height)
    {
        foreach ($this->temporaryActions as $action) {
            $this->actionFactory->destroyAction($action);
        }

        $lineHeight = 4.5;


        $frame = new Frame();
        $frame->setPosition(0, 0);
        $frame->setSize($width, $height);

        $posY = 0.;

        $tooltip = $this->uiFactory->createTooltip();
        $frame->addChild($tooltip);

        // Generating headers.
        $data = [];
        foreach ($this->columns as $columnData) {
            $action = null;
            $sort = "";
            if ($columnData->getSortable() && $columnData->getSortColumn()) {
                $sort = $columnData->getSortDirection();

            }
            if ($columnData->getSortable()) {
                $action = $this->actionFactory->createManialinkAction(
                    $this->manialink,
                    [$this, 'sortColumn'],
                    ["key" => $columnData->getKey()]
                );
            }

            $data[] = [
                'title' => $columnData->getName(),
                'width' => $columnData->getWidthCoeficiency(),
                'translatable' => true,
                'sort' => $sort,
                'action' => $action,
            ];
        }

        $frame->addChild($this->titleLineFactory->create($frame->getWidth(), $data));
        $posY -= $lineHeight + 1;

        /*
         * Display the main content.
         */
        $this->dataCollection->setPageSize(floor(($frame->getHeight() + $posY - $lineHeight - 2) / $lineHeight));

        $lines = $this->dataCollection->getData($this->currentPage);
        $idx = 0;
        foreach ($lines as $i => $lineData) {
            $data = [];
            foreach ($this->columns as $columnData) {
                if ($columnData instanceof TextColumn) {
                    $data[] = [
                        'text' => $this->dataCollection->getLineData($lineData, $columnData->getKey()),
                        'width' => $columnData->getWidthCoeficiency(),
                        'translatable' => $columnData->getTranslatable(),
                    ];
                } else {
                    if ($columnData instanceof IconColumn) {
                        $data[] = [
                            'iconUrl' => $this->dataCollection->getLineData($lineData, $columnData->getKey()),
                            'width' => $columnData->getWidthCoeficiency(),
                            'iconWidth' => 4,
                        ];
                    } elseif ($columnData instanceof ActionColumn) {
                        $action = $this->actionFactory
                            ->createManialinkAction($this->manialink, $columnData->getCallable(), $lineData);
                        $this->temporaryActions[] = $action;
                        $data[] = [
                            'renderer' => clone $columnData->getRenderer(),
                            'width' => $columnData->getWidthCoeficiency(),
                            'action' => $action,
                        ];
                    } elseif ($columnData instanceof InputColumn) {
                        $value = $this->dataCollection->getLineData($lineData, $columnData->getKey());

                        $data[] = [
                            'input' => $value,
                            'index' => $i,
                            'tooltip' => $tooltip,
                            'width' => $columnData->getWidthCoeficiency(),
                        ];
                    }
                }
            }
            $line = $this->lineFactory->create($frame->getWidth(), $data, $idx++);
            $line->setPosition(0, $posY);
            $frame->addChild($line);
            $posY -= $lineHeight;
        }

        /*
         * Handle the pager.
         */
        $posY = ($frame->getHeight() - 9) * -1;
        $pager = $this->pagerFactory->create(
            $frame->getWidth(),
            $this->currentPage,
            $this->dataCollection->getLastPageNumber(),
            $this->actionFirstPage,
            $this->actionPreviousPage,
            $this->actionNextPage,
            $this->actionLastPage,
            $this->actionGotoPage
        );
        $pager->setPosition(($frame->getWidth() - $pager->getWidth()) / 2, $posY);
        $frame->addChild($pager);

        return $frame;
    }
746052
protected function cacheResponse(RequestInterface $request, Response $response, $ttl = null)
    {
        if (!$this->isSupportedMethod($request)) {
            return;
        }

        $cacheTtl = $ttl ?: $this->getCachettl($response);

        // do we have a valid ttl to set the cache ?
        if ($cacheTtl <= 0) {
            return;
        }

        if (($statusCode = $response->getStatusCode()) >= 500 && !$this->cacheServerErrors) {
            return;
        }

        if (($statusCode < 500 && $statusCode >= 400) && !$this->cacheClientErrors) {
            return;
        }

        // copy response in array to  store
        $cached = new \SplFixedArray(5);
        $cached[0] = $statusCode;
        $cached[1] = $response->getHeaders();
        $cached[2] = $response->getBody()->__toString();
        $cached[3] = $response->getProtocolVersion();
        $cached[4] = $response->getReasonPhrase();

        return $this->cache->set(
            self::getKey($request),
            serialize($cached),
            $cacheTtl
        );
    }
419265
protected function drawLine($image, $width, $height, $tcol = null)
    {
        if ($tcol === null) {
            $tcol = imagecolorallocate($image, mt_rand(100, 255), mt_rand(100, 255), mt_rand(100, 255));
        }
        if (mt_rand(0, 1)) { // Horizontal
            $Xa   = mt_rand(0, $width/2);
            $Ya   = mt_rand(0, $height);
            $Xb   = mt_rand($width/2, $width);
            $Yb   = mt_rand(0, $height);
        } else { // Vertical
            $Xa   = mt_rand(0, $width);
            $Ya   = mt_rand(0, $height/2);
            $Xb   = mt_rand(0, $width);
            $Yb   = mt_rand($height/2, $height);
        }
        imagesetthickness($image, mt_rand(1, 3));
        imageline($image, $Xa, $Ya, $Xb, $Yb, $tcol);
    }
542913
public function resizeTo(
        int $width,
        int $height,
        bool $maintain_aspect = true,
        array $canvas_color = array('r' => 255, 'g' => 255, 'b' => 255)
    ) : ImageResize
    {
        if ($this->resizer !== null) {
            try {
                $this->resizer->setOptions($width, $height, $this->quality, $maintain_aspect, $canvas_color);
            } catch (\Exception $e) {
                echo $e->getMessage();
            }
        }

        return $this;
    }
1008906
protected function getNewHeight($width, $height) 
    {
        if ($height > 0) {
            return $height;
        }
        
        // original width : new width = original height : X
        return $width * $this->imageInfo['height'] / $this->imageInfo['width'];
    }
419610
protected function do_resize(\stdClass $src, $width, $height) {

		$src->resource->resizeImage($width, $height, \Imagick::FILTER_CATROM, 1, FALSE);
		$src->resource->convolveImage([-1, -0.8, -1, -0.8, 16, -0.8, -1, -0.8, -1]);
		
		$src->width		= $width;
		$src->height	= $height;

		return $src;
		
	}
501575
public function resize(int $width = 0, int $height = 0)
    {
        $this->instance->scaleImage($width, $height);
    }
728622
public function canvas($width, $height, $background = null)
    {
        return $this->createDriver()->newImage($width, $height, $background);
    }
1319234
public function paperSize($width,$height)
    {
        $this->paperWidth = $width;
        $this->paperHeight = $height;
        return $this;
    }
235489
public function resizeOut($width, $height)
        {
            if (false === $this->_options['resizeUp']) {
                $this->_maxHeight = (intval($height) > $this->_sourceHeight) ? $this->_sourceHeight:$height;
                $this->_maxWidth = (intval($width) > $this->_sourceWidth) ? $this->_sourceWidth:$width;
            } else {
                $this->_maxHeight = intval($height);
                $this->_maxWidth = intval($width);
            }

            list($newWidth, $newHeight) = $this->_calcImageSizeStrict($this->_sourceWidth, $this->_sourceHeight);

            // resize the image to be close to our desired dimensions
            $this->resizeIn($newWidth, $newHeight);

            return $this;
        }
1103156
public function prosize(Int $width, Int $height = 0) : Thumb
    {
        $this->sets['prowidth']  = $width;
        $this->sets['proheight'] = $height;

        return $this;
    }
602815
public function windowSize($width,$height)
    {
        $this->windowWidth  = $width;
        $this->windowHeight = $height;
        return $this;
    }
10381
public function size(Int $width, Int $height) : Thumb
    {
        $this->sets['width']  = $width;
        $this->sets['height'] = $height;

        return $this;
    }
229588
public function do_resize($width, $height)
    {
        $this->_image->scaleImage($width, $height);

        $this->_width = $this->_image->getImageWidth();
        $this->_height = $this->_image->getImageHeight();

        return $this;
    }