…

@param resource $imageResource
@return \Beluga\Drawing\Rectangle
171069
public static function FromImageResource( $imageResource ) : Rectangle
   {

      return new Rectangle(
         new Point(),
         new Size( \imagesx( $imageResource ), \imagesy( $imageResource ) )
      );

   }
150742
public static function create($contentDescription = null, $imageSources = []): self
    {
        $image = new self();

        $image->contentDescription = $contentDescription;
        $image->sources            = $imageSources;

        return $image;
    }
1108664
public function image($width = null, $height = null, array $options = [])
    {
        $url = $this->getImageUrlOrDefault();

        if (pathinfo($url, PATHINFO_EXTENSION) === 'svg') {
            return $url;
        }

        return url(Croppa::url($url, $width, $height, $options));
    }
431572
public function newImage($width, $height, $background = null)
    {
        // create empty resource
        $core = imagecreatetruecolor($width, $height);
        $image = new \Intervention\Image\Image(new static, $core);

        // set background color
        $background = new Color($background);
        imagefill($image->getCore(), 0, 0, $background->getInt());

        return $image;
    }
14915
protected function _analyzeSourceImage($imageResource, $imageType) {
        $this->_params['sourceWidth'] = imagesx($imageResource);
        $this->_params['sourceHeight'] = imagesy($imageResource);
        $this->_params['mime'] = image_type_to_mime_type($imageType);
        $this->_params['type'] = $imageType;
    }
789927
public static function LoadFile( string $imageFile ) : GdImage
   {

      if ( ! \file_exists( $imageFile ) )
      {
         throw new FileNotFoundError(
            'Drawing.Image', $imageFile, 'Loading a \Beluga\Drawing\Image\GdImage Resource from this file fails.'
         );
      }

      $imageInfo = null;

      try
      {
         if ( false === ( $imageInfo = \getimagesize( $imageFile ) ) )
         {
            throw new \Exception( 'Defined imagefile uses a unknown file format!' );
         }
      }
      catch ( \Throwable $ex )
      {
         throw new FileAccessError(
            'Drawing.Image', $imageFile, FileAccessError::ACCESS_READ, $ex->getMessage()
         );
      }

      $img  = null;
      $mime = null;

      switch ( $imageInfo[ 'mime' ] )
      {

         case 'image/png':
            $img = \imagecreatefrompng( $imageFile );
            $mime = 'image/png';
            break;

         case 'image/gif':
            $img = \imagecreatefromgif( $imageFile );
            $mime = 'image/gif';
            break;

         default:
            $img = \imagecreatefromjpeg( $imageFile );
            $mime = 'image/jpeg';
            break;

      }

      return new GdImage(
         $img,
         new Size( $imageInfo[ 0 ], $imageInfo[ 1 ] ),
         $mime,
         $imageFile
      );

   }
821321
protected function initDestImageResource() 
    {
    	// gif does not supports truecolor for resize
    	if (function_exists("ImageCreateTrueColor") && $this->getExtension() != 'gif') {
    		$this->destImageResource = ImageCreateTrueColor($this->destImageWidth, $this->destImageHeight);
    	} else {
    		$this->destImageResource = ImageCreate($this->destImageWidth, $this->destImageHeight);
    	}
    	
    	return $this;
    }
1075136
public function draw($image)
    {

        list($x, $y) = $this->pos;
        $left = $x + $this->width / 2;
        $top = $y + $this->height / 2;

        if( null !== $this->fillColor ){
            list($r, $g, $b, $alpha) = $this->fillColor->getRgba();
            $fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
            imagefilledellipse($image->getCore(), $left, $top, $this->width, $this->height, $fillColorResource);
        }
        // Create borders. It will be placed on top of the filled ellipse (if present)
        if ( 0 < $this->getBorderSize() and null !== $this->borderColor) { // With border > 0 AND borderColor !== null
            list($r, $g, $b, $alpha) = $this->borderColor->getRgba();
            $borderColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
            imageellipse($image->getCore(), $left, $top, $this->width, $this->height, $borderColorResource);
        }

        return $image;
    }
825914
public function getImageResized($width = null, $height = null, $method = null)
    {
        if ($this->hasImage()) {
            
            $image = $this->getSlideImage();
            
            if ($width || $height || $method) {
                return ImageTools::singleton()->resize($image, $width, $height, $method);
            }
            
            if ($this->getParent()->hasMethod('performImageResize')) {
                return $this->getParent()->performImageResize($image);
            }
            
            return $image;
            
        }
    }
57648
public function newImage($width, $height, $background = 'white')
    {
        $this->resource->createNew($width, $height, $background);

        return $this;
    }
783925
protected function assertResource($resource)
    {
        if (!is_resource($resource) || get_resource_type($resource) !== 'gd') {
            throw new InvalidArgumentException('Invalid resource type.');
        }

        $width = imagesx($resource);
        $height = imagesy($resource);
        if ($width < 1 || $height < 1) {
            throw new InvalidImageDimensionException(
                sprintf('The resource image dimensions should be at least 1x1px. The resource image with %sx%spx dimensions given.', $width, $height)
            );
        }
    }
20620
public function match($sourceImage) : GD
    {
        if( ! is_resource($sourceImage) )
        {
            throw new InvalidArgumentException(NULL, '[resource]');
        }

        imagecolormatch($this->canvas, $sourceImage);

        return $this;
    }
1153172
public function load($url)
    {
        if (file_exists($url)) {
            return $this->validate($url);
        }

        if (preg_match('#^(https?|spdy)://#', $url)) {

            if ($file = $this->loadRemoteFile($url)) {
                return $this->validate($file);
            }
        }

        throw new ImageResourceLoaderException(sprintf('Invalid Source URL: %s', $url));
    }
886308
public function tile($tile) : GD
    {
        if( ! is_resource($tile) )
        {
            throw new InvalidArgumentException(NULL, '[resource]');
        }

        imagesettile($this->canvas, $tile);

        return $this;
    }
1324588
public function saveImageResource(ImageResource $imageResource) {
		$resource = $imageResource->getHandle();
		imagesavealpha($resource, true);
		IoUtils::imagePng($resource, $this->getFileName(), 9, PNG_ALL_FILTERS);
	}
706181
public function render($destImagePath = null) 
    {
    	$this->initDestImageResource();
    	$this->applyTransparency();
    	
    	ImageCopyResampled(
	    	$this->destImageResource,
	    	$this->sourceImageResource,
	    	0, 0, 0, 0,
	    	$this->destImageWidth,
	    	$this->destImageHeight,
	    	$this->imageInfo['width'],
	    	$this->imageInfo['height']
    	);
    	
        // Let's try to delete the image if already exists
        if(null !== $destImagePath) {
            if (is_file($destImagePath) && file_exists($destImagePath)) {
                if (!unlink($destImagePath)) {
                    throw new \RuntimeException("File '" . $destImagePath . "' already exists and it is *not* writeable");
                }
            }
        } else {
            header('Content-type: ' . $this->imageInfo['mime']);
        }
        
		switch($this->getExtension()) {
		case 'gif':
			return ImageGif($this->destImageResource, $destImagePath);
			break;
            
		case 'jpg':
			return ImageJpeg($this->destImageResource, $destImagePath, $this->getQuality());
            break;
            
		case 'png':
			return ImagePng($this->destImageResource, $destImagePath);
            break;
        }
        
        return false;
    }
709315
public function apply($imageRessource)
  {
    $width = imagesx($imageRessource);
    $height = imagesy($imageRessource);
    for ($x = 0; $x < $width; $x++) {
      for ($y = 0; $y < $height; $y++) {
        $color = imagecolorallocatealpha($imageRessource, $this->red, $this->green, $this->blue, $this->opacity);
        imagesetpixel($imageRessource, $x, $y, $color);
      }
    }
    return $imageRessource;
  }