Get a dimension.
@param  Image       $image The source image.
@param  string      $field The requested field.
@return double|null The dimension.
382
public function getDimension(Image $image, $field)
    {
        if ($this->{$field}) {
            return (new Dimension($image, $this->getDpr()))->get($this->{$field});
        }
    }
313173
protected function fetchImage($image) {
    $value = NULL;
    $files = $this->fileStorage->loadByProperties([
      'uuid' => $image,
    ]);

    if ($files) {
      return current($files);
    }

    return $value;
  }
686046
public function applyToImage(Image $image, $x = 0, $y = 0)
    {
        return parent::applyToImage($image, $x, $y);
    }
1073204
public function run(Image $image)
    {
        $pixelate = $this->getPixelate();

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

        return $image;
    }
435667
public function image($image, $width=null, $height=null, $alt=null, $class=null, $link=null, $caption=null, $srcset=null) {
		$image = $this->getLink($image);
		$attributes = $this->getHtmlAttributes(array(
			'width'=>$width,
			'height'=>$height,
			'alt'=>$alt,
			'caption'=>$caption,
			'class'=>$class,
			'srcset'=>$srcset
		));

		$img = "<img src='$image'$attributes />";
		if (!is_null($link)) {
			$link = $this->getLink($link);
			return "<a href='$link'>$img</a>";
		}

		return $img;
	}
1283151
public function execute($image)
    {
        $x1 = $this->argument(0)->type('numeric')->required()->value();
        $y1 = $this->argument(1)->type('numeric')->required()->value();
        $x2 = $this->argument(2)->type('numeric')->required()->value();
        $y2 = $this->argument(3)->type('numeric')->required()->value();
        $callback = $this->argument(4)->type('closure')->value();

        $namespace = $image->getDriver()->getNamespace();
        $rectangle_classname = "\{$namespace}\Shapes\RectangleShape";

        $rectangle = new $rectangle_classname($x1, $y1, $x2, $y2);

        if ($callback instanceof Closure) {
            $callback($rectangle);
        }

        $rectangle->applyToImage($image, $x1, $y1);

        return true;
    }
472318
public function apply( $image ) {

        $size = $this->amount;
        $width = $image->getWidth();
        $height = $image->getHeight();
        $image->getCore()->scaleImage(max(1, ($width / $size)), max(1, ($height / $size)));
        $image->getCore()->scaleImage($width, $height);
        return $image;
    }
333270
public function run(Image $image)
    {
        $brightness = $this->getBrightness();

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

        return $image;
    }
1094941
protected function thumbnailResize(Image $image, $width, $height)
    {
        return $image->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
        });
    }
731539
public function resolveMissingDimensions(Image $image, $width, $height)
    {
        if (is_null($width) and is_null($height)) {
            $width = $image->width();
            $height = $image->height();
        }

        if (is_null($width)) {
            $width = $height * ($image->width() / $image->height());
        }

        if (is_null($height)) {
            $height = $width / ($image->width() / $image->height());
        }

        return [
            (int) $width,
            (int) $height,
        ];
    }
5863
public function getImageSize($Image = null) {
		$Image = $this->_getImage($Image);
		$BoxInterface = $Image->getSize($Image);
		return [
			$BoxInterface->getWidth(),
			$BoxInterface->getHeight(),
			'x' => $BoxInterface->getWidth(),
			'y' => $BoxInterface->getHeight()
		];
	}
60827
private Dimension getImageDimension() {
    Dimension dimension = null;

    // check for cropping dimension
    if (this.media.getCropDimension() != null) {
      dimension = this.media.getCropDimension();
    }
    else {
      // if binary is image try to calculcate dimensions by loading it into a layer
      Layer layer = this.resource.adaptTo(Layer.class);
      if (layer != null) {
        dimension = new Dimension(layer.getWidth(), layer.getHeight());
      }
    }

    return dimension;
  }
341765
public function setImage($image, $getAndSetDimensions = true)
    {
        $this->set('image', $image);
        if ($getAndSetDimensions) {
            $imageSize = $this->container->get(ImageService::class)->getImageSize($image);
            if (is_array($imageSize) && count($imageSize)) {
                $this->set('og:image:width', $imageSize[0], true);
                $this->set('og:image:height', $imageSize[1], true);
            }
        }
    }
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);
    }
1355831
public function getImagePath(Image $file, $sizeName = null)
	{
		if ( ! $file instanceof Image) {
			throw new Exception\RuntimeException('Image entity expected');
		}

		$path = $this->getFilesystemDir($file);
		$size = $file->findImageSize($sizeName);
				
		if ($size instanceof ImageSize) {
			$path .= self::RESERVED_DIR_SIZE 
					. DIRECTORY_SEPARATOR
					. $size->getFolderName() 
					. DIRECTORY_SEPARATOR;
		}

		$path .= $file->getRealFileName();

		return $path;
	}
1022667
public function getField($field)
    {
        return isset($this->data[$field]) ? $this->data[$field] : null;
    }
257755
private function getDimensionsFromDB($dim = "string") {
        $imageDimensions = $this->ImageDim;
        if (!$imageDimensions) {
            return null;
        }
        if ($dim === 'string') {
            return $imageDimensions;
        }
        $widthAndHeight = explode('x', $imageDimensions);
        if (!isset($widthAndHeight[$dim])) {
            return null;
        }
        return (int)$widthAndHeight[$dim];
    }