Resolve border amount.
@param  Image  $image The source image.
@return string The resolved border amount.
966978
public function getBorder(Image $image)
    {
        if (!$this->border) {
            return;
        }

        $values = explode(',', $this->border);

        $width = $this->getWidth($image, $this->getDpr(), isset($values[0]) ? $values[0] : null);
        $color = $this->getColor(isset($values[1]) ? $values[1] : null);
        $method = $this->getMethod(isset($values[2]) ? $values[2] : null);

        if ($width) {
            return [$width, $color, $method];
        }
    }
509457
public static function getImageInfo($image)
    {
        $imagesInfoArr = @getimagesize($image);
        if (!$imagesInfoArr) return false;
        list($imagesInfo['width'], $imagesInfo['height'], $imagesInfo['ext']) = $imagesInfoArr;
        $imagesInfo['ext'] = strtolower(ltrim(image_type_to_extension($imagesInfo['ext']), '.'));
        return $imagesInfo;
    }
958585
public function execute($image)
    {
        $color = $this->argument(0)->required()->value();
        $color = new Color($color);
        $x = $this->argument(1)->type('digit')->required()->value();
        $y = $this->argument(2)->type('digit')->required()->value();

        return imagesetpixel($image->getCore(), $x, $y, $color->getInt());
    }
1119811
private function getText($image)
    {
        $rtn = '';
        $w = imagesx($image);
        $h = imagesy($image);
        for ($y = 0; $y < $h; ++$y) {
            for ($x = 0; $x < $w; ++$x) {
                $rgb = imagecolorat($image, $x, $y);
                $rtn .= $this->getDotFromRgb($rgb);
            }
        }

        return $rtn;
    }
217138
public function process(Image $image, $command_line = '') {
        $result = new Result();

        $result->setCommandLine($command_line . ' -bordercolor ' . escapeshellarg($this->color)
            . ' -border ' . escapeshellarg($this->leftRight . 'x' . $this->topBottom));

        return $result;
    }
1319943
protected function postEffect($image)
    {
        if (!function_exists('imagefilter')) {
            return;
        }

        if ($this->backgroundColor != null || $this->textColor != null) {
            return;
        }

        // Negate ?
        if ($this->rand(0, 1) == 0) {
            imagefilter($image, IMG_FILTER_NEGATE);
        }

        // Edge ?
        if ($this->rand(0, 10) == 0) {
            imagefilter($image, IMG_FILTER_EDGEDETECT);
        }

        // Contrast
        imagefilter($image, IMG_FILTER_CONTRAST, $this->rand(-50, 10));

        // Colorize
        if ($this->rand(0, 5) == 0) {
            imagefilter($image, IMG_FILTER_COLORIZE, $this->rand(-80, 50), $this->rand(-80, 50), $this->rand(-80, 50));
        }
    }
178731
public function applyToImage(Image $image, $x = 0, $y = 0)
    {
        $polygon = new \ImagickDraw;

        // set background
        $bgcolor = new Color($this->background);
        $polygon->setFillColor($bgcolor->getPixel());

        // set border
        if ($this->hasBorder()) {
            $border_color = new Color($this->border_color);
            $polygon->setStrokeWidth($this->border_width);
            $polygon->setStrokeColor($border_color->getPixel());
        }

        $polygon->polygon($this->points);

        $image->getCore()->drawImage($polygon);

        return true;
    }
284169
public function run(Image $image)
    {
        $contrast = $this->getContrast();

        if ($contrast !== null) {
            $image->contrast($contrast);
        }

        return $image;
    }
1304364
private function getPathsForVolumeAsset($image)
    {
        try {
            $this->transformPath = ImagerHelpers::getTransformPathForAsset($image);
        } catch (InvalidConfigException $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }

        $runtimeImagerPath = Craft::$app->getPath()->getRuntimePath().'/imager/';

        $this->url = $image->getUrl();
        $this->path = FileHelper::normalizePath($runtimeImagerPath.$this->transformPath.'/');
        $this->filename = $image->getFilename();
        $this->basename = $image->getFilename(false);
        $this->extension = $image->getExtension();

        try {
            FileHelper::createDirectory($this->path);
        } catch (Exception $e) {
            Craft::error($e->getMessage(), __METHOD__);
            throw new ImagerException($e->getMessage(), $e->getCode(), $e);
        }
    }
496615
public function getImageCaption($image): ?string
    {
        if (null === ($file = $this->container->get('huh.utils.file')->getFileFromUuid($image))) {
            return null;
        }

        $meta = StringUtil::deserialize($file->getModel()->meta, true);

        if (!isset($meta[$GLOBALS['TL_LANGUAGE']]['caption'])) {
            return null;
        }

        return $meta[$GLOBALS['TL_LANGUAGE']]['caption'];
    }
1008063
public function execute($image)
    {
        $level = $this->argument(0)->between(-100, 100)->required()->value();

        return imagefilter($image->getCore(), IMG_FILTER_CONTRAST, ($level * -1));
    }
293543
public function apply( $image ) {

        imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $this->red, $this->green, $this->blue);
        return $image;
    }
449861
public function runOverlay(Image $image, $width, $color)
    {
        return $image->rectangle(
            $width / 2,
            $width / 2,
            $image->width() - ($width / 2),
            $image->height() - ($width / 2),
            function ($draw) use ($width, $color) {
                $draw->border($width, $color);
            }
        );
    }
69458
private function constructImage ($image, $boundary)
    {

        // Set variables

        $output	= NULL;

        // Add the boundary

        $output	.= '--' . $boundary . $this->_nl;

        // Add the image to the message

        $output	.= 'Content-Type: ' . $image['type'];

        if ($image['name'])
        {
            $output	.= '; name="' . $image['name'] . '"';
        }

        $output	.= $this->_nl;
        $output	.= 'Content-Transfer-Encoding: base64' . $this->_nl;
        $output	.= 'Content-ID: <' . $image['cid'] . '>' . str_repeat ($this->_nl, 2);
        $output	.= chunk_split (base64_encode ($image['data']), 70) . $this->_nl;

        // Return image part

        return $output;

    }
183746
public function execute($image)
    {
        $width = $this->argument(0)->type('digit')->required()->value();
        $height = $this->argument(1)->type('digit')->required()->value();
        $anchor = $this->argument(2)->value('center');
        $relative = $this->argument(3)->type('boolean')->value(false);
        $bgcolor = $this->argument(4)->value();

        $original_width = $image->getWidth();
        $original_height = $image->getHeight();

        // check of only width or height is set
        $width = is_null($width) ? $original_width : intval($width);
        $height = is_null($height) ? $original_height : intval($height);

        // check on relative width/height
        if ($relative) {
            $width = $original_width + $width;
            $height = $original_height + $height;
        }

        // check for negative width/height
        $width = ($width <= 0) ? $width + $original_width : $width;
        $height = ($height <= 0) ? $height + $original_height : $height;

        // create new canvas
        $canvas = $image->getDriver()->newImage($width, $height, $bgcolor);

        // set copy position
        $canvas_size = $canvas->getSize()->align($anchor);
        $image_size = $image->getSize()->align($anchor);
        $canvas_pos = $image_size->relativePosition($canvas_size);
        $image_pos = $canvas_size->relativePosition($image_size);

        if ($width <= $original_width) {
            $dst_x = 0;
            $src_x = $canvas_pos->x;
            $src_w = $canvas_size->width;
        } else {
            $dst_x = $image_pos->x;
            $src_x = 0;
            $src_w = $original_width;
        }

        if ($height <= $original_height) {
            $dst_y = 0;
            $src_y = $canvas_pos->y;
            $src_h = $canvas_size->height;
        } else {
            $dst_y = $image_pos->y;
            $src_y = 0;
            $src_h = $original_height;
        }

        // make image area transparent to keep transparency
        // even if background-color is set
        $transparent = imagecolorallocatealpha($canvas->getCore(), 255, 255, 255, 127);
        imagealphablending($canvas->getCore(), false); // do not blend / just overwrite
        imagefilledrectangle($canvas->getCore(), $dst_x, $dst_y, $dst_x + $src_w - 1, $dst_y + $src_h - 1, $transparent);

        // copy image into new canvas
        imagecopy($canvas->getCore(), $image->getCore(), $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);

        // set new core to canvas
        $image->setCore($canvas->getCore());

        return true;
    }
1135004
public function getImageWidth($image): ?string
    {
        if (null === ($file = $this->container->get('huh.utils.file')->getFileFromUuid($image))) {
            return null;
        }

        return $file->width;
    }
1073204
public function run(Image $image)
    {
        $pixelate = $this->getPixelate();

        if ($pixelate !== null) {
            $image->pixelate($pixelate);
        }

        return $image;
    }