Get bounding box

@param ImageInterface $image
@return BoxInterface
10476
private function getBoundingBox(ImageInterface $image)
    {
        $box = $image->getSize()->widen($this->size->getWidth());
        if ($box->getHeight() >= $this->size->getHeight()) {
            return $box;
        }

        return $image->getSize()->heighten($this->size->getHeight());
    }
1029304
public function execute($image)
    {
        $width = $this->argument(0)->type('digit')->required()->value();
        $additionalConstraints = $this->argument(1)->type('closure')->value();

        $this->arguments[0] = $width;
        $this->arguments[1] = null;
        $this->arguments[2] = function ($constraint) use ($additionalConstraints) {
            $constraint->aspectRatio();
            if(is_callable($additionalConstraints))
                $additionalConstraints($constraint);
        };

        return parent::execute($image);
    }
1222741
public function setImage($image)
    {
        if (getimagesize($image)) {
            if (strpos($image, 'http') === false) {
                loader()->loadHelper('url');
                $image = images_url($image);
            }

            $this->setObject('image', $image);
        }

        return $this;
    }
1021674
public function getImage(Image $image)
    {
        if (is_null($this->watermarks)) {
            return;
        }

        if (!is_string($this->mark)) {
            return;
        }

        if ($this->mark === '') {
            return;
        }

        $path = $this->mark;

        if ($this->watermarksPathPrefix) {
            $path = $this->watermarksPathPrefix.'/'.$path;
        }

        if ($this->watermarks->has($path)) {
            $source = $this->watermarks->read($path);

            if ($source === false) {
                throw new FilesystemException(
                    'Could not read the image `'.$path.'`.'
                );
            }

            return $image->getDriver()->init($source);
        }
    }
354362
public function applyFilter(Image $image)
    {
        if ($image->width() >= $image->height())
        {
            return $image->resize(272, null, function ($constraint)
            {
                $constraint->aspectRatio();
            });
        }

        return $image->resize(null, 272, function ($constraint)
        {
            $constraint->aspectRatio();
        });
    }
862734
private function toRGB(ImageInterface $image)
    {
        if ('cmyk' == $image->palette()->name()) {
            $image->usePalette(new RGB());
        }

        return $image;
    }
380481
public function canBeApplied(ImagineImageInterface $image)
    {
        $expectedDimensions = $this->calculateDimensions($image->getSize());

        return ((string)$expectedDimensions !== (string)$image->getSize());
    }
914111
public function execute($image)
    {
        $width = $this->argument(0)->type('digit')->required()->value();
        $height = $this->argument(1)->type('digit')->required()->value();
        $x = $this->argument(2)->type('digit')->value();
        $y = $this->argument(3)->type('digit')->value();

        if (is_null($width) || is_null($height)) {
            throw new \Intervention\Image\Exception\InvalidArgumentException(
                "Width and height of cutout needs to be defined."
            );
        }

        $cropped = new Size($width, $height);
        $position = new Point($x, $y);

        // align boxes
        if (is_null($x) && is_null($y)) {
            $position = $image->getSize()->align('center')->relativePosition($cropped->align('center'));
        }

        // crop image core
        return $this->modify($image, 0, 0, $position->x, $position->y, $cropped->width, $cropped->height, $cropped->width, $cropped->height);
    }
803382
public function draw($image)
    {

        $strokeColor = new \ImagickPixel($this->getColor()->getHexString());

        $draw = new \ImagickDraw();

        $draw->setStrokeColor($strokeColor);

        $draw->setStrokeWidth($this->thickness);

        list($x1, $y1) = $this->point1;
        list($x2, $y2) = $this->point2;
        $draw->line($x1, $y1, $x2, $y2);

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

        return $image;
    }
270842
public function applyFilter(Image $image)
    {
        $image->fit($this->params["w"], $this->params["h"]);

        return $image;
    }
1208814
public function optimize(Image $image): Image
    {
        $binary = $this->manipulate($image->getBinary(), 'optimize', $this->optimizationParams);

        return $image->modify($binary);
    }
851117
private function getSizeByFixedHeight(ImageInterface $image, $newHeight)
    {
        $box   = $image->getSize();
        $ratio = $box->getWidth() / $box->getHeight();

        $newWidth = $newHeight * $ratio;

        return $newWidth;
    }
991786
public function setImage($image) {

		if(false === is_string($image)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($image)), E_USER_ERROR);
		}

		$file = new File($image);

		if(false === $file -> exists()) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be an existing image', __METHOD__), E_USER_ERROR);
		}

		if(false === in_array(exif_imagetype($image), [IMAGETYPE_JPEG, IMAGETYPE_PNG])) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be an valid image (jpg, jpeg or png)', __METHOD__), E_USER_ERROR);
		}

		$this -> image = $file;

		return $this;
	}
236812
public function setImage($image)
    {
        if (!is_null($image) && !$image instanceof ComActivitiesActivityMedialinkInterface) {
            throw new InvalidArgumentException('Invalid image type.');
        }

        $this->image = $image;
        return $this;
    }
69263
public function setImage(\Core\Entity\Image $image = null) {
        $this->image = $image;

        return $this;
    }
1234692
public function addImage(\Elcodi\Component\Media\Entity\Interfaces\ImageInterface $image)
    {
        $this->images->add($image);

        return $this;
    }
534867
protected function resizeCrop(ImageInterface $image, $width, $height, $enlarge = true)
    {
        $size = $image->getSize();

        if ($enlarge === false && $size->getWidth() < $width) {
            $width = $size->getWidth();
        }

        if ($enlarge === false && $size->getHeight() < $height) {
            $height = $size->getHeight();
        }

        list($optimal_width, $optimal_height) = $this->getOptimalCrop($size, $width, $height, $enlarge);

        // Find center - this will be used for the crop
        $center_x = ($optimal_width / 2) - ($width / 2);
        $center_y = ($optimal_height / 2) - ($height / 2);

        return $image->resize(new Box($optimal_width, $optimal_height))
            ->crop(new Point($center_x, $center_y), new Box($width, $height));
    }