Sets image resource as new image

@param resource $resource image resource
192586
public function setResource($resource) {
        $this->resource = $resource;
        $this->width = imagesx($resource);
        $this->height = imagesy($resource);
    }
169760
public function resource($name, $resource = null)
    {
        if ($resource) {
            $this->addResource($name, $resource);
        } else {
            return $this->getResource($name);
        }
    }
1269947
protected function convertResourceToObject($resource, $resourceId = null)
    {
        return ! $resource instanceof Resource ? new SimpleResource($resource, $resourceId) : $resource;
    }
757876
public function apply($resource){
		// Extract arguments
		@list(,$x,$y,$width,$height)=func_get_args();
		$x=(int)$x;
		$y=(int)$y;
		$width=(int)$width;
		$height=(int)$height;
		// Get resolution
		$w_src=imagesx($resource);
		$h_src=imagesy($resource);
		if($w_src===false || $h_src===false){
			throw new Exception("An error was encountered while getting source image resolution");
		}
		// Verifications
		if(!$width || !$height){
			throw new Exception("Invalid image resolution provided");
		}
		if(($x+$width)>$w_src || ($y+$height)>$h_src){
			throw new Exception("Dimensions provided seems to be out of the image resolution");
		}
		// Create new image
		$image=$this->_createTrueColor($width,$height);
		// Cut image
		if(!imagecopy($image,$resource,0,0,$x,$y,$width,$height)){
			throw new Exception("Failed to copy image portion");
		}
		return $image;
	}
877102
protected function setupIndexReferences($resource)
    {
        foreach ($resource->settings['actions']['IndexReferences']['uris'] as $property => $uri) {
            $this->setupIndex($resource, $uri, $property);
        }
    }
385139
public function addResource(ResourceInterface $resource, $name = null) {
		if ($name === null) {
			$this->resources[] = $resource;
			
			return $this;
		}
		
		$this->resources[$name] = $resource;
		
		return $this;
	}
447472
public function apply($resource){
		// Verify support
		if(!function_exists('imagerotate')){
			throw new Exception("It seems your PHP version is not compiled with the bundled version of the GD library");
		}
		// Get arguments
		@list(,$angle,$color)=func_get_args();
		$angle=(float)$angle;
		if(!$color){
			$color='#FFFFFF';
		}
		$rgb=html2rgb($color);
		// Apply effect
		$resource=imagerotate($resource,$angle,imagecolorallocate($resource,$rgb[0],$rgb[1],$rgb[2]));
		if(!$resource){
			throw new Exception("Image rotation failed");
		}
		return $resource;
	}
1131833
public function attach($resource){
        if(!is_resource($resource) || "stream" !== get_resource_type($resource)){
            throw new \InvalidArgumentException(
                "Argument must be of the type stream resource, " . gettype($resource) . " given."
            );
        }

        $this->resource = $resource;
    }
771133
public static function load($color, $resource)
    {
        if ($color === 'transparent') {

            return imagecolorallocatealpha($resource, 0, 0, 0, 127);
        }

        $gdpixel = new GDPixel($color);

        return imagecolorallocate($resource, $gdpixel->channelR, $gdpixel->channelG, $gdpixel->channelB);
    }
410795
public function setResource(ResourceInterface $resource = null)
    {
        $this->resource = $resource;

        // Clear urls
        $this->urls = null;

        return $this;
    }
950518
public void setImage(Resource resource)
    {
        ImageIcon image = null;
        if (resource != null && resource.exists())
        {
            try
            {
                image = new ImageIcon(resource.getURL());
            }
            catch (IOException e)
            {
                logger.warn("Error reading resource: " + resource);
                throw new RuntimeException("Error reading resource " + resource, e);
            }
        }
        setImage(image);
    }
733936
public function addResource(ResourceInterface $resource, $loader)
    {
        $this->resources[$loader][] = $resource;
        $this->loaded = false;
    }
1129273
public function generate(Resource $resource, array $data = array()) : void
    {
        $filepath  = $resource->getSrcFilename();
        $name      = $data['name'];
        $arguments = $data['arguments'];

        $argString = $this->argumentBuilder->buildFrom($arguments);

        $values = array('%name%' => $name, '%arguments%' => $argString);
        if (!$content = $this->templates->render('method', $values)) {
            $content = $this->templates->renderString(
                $this->getTemplate(), $values
            );
        }

        $code = $this->filesystem->getFileContents($filepath);
        $code = preg_replace('/}[ \n]*$/', rtrim($content) ."\n}\n", trim($code));
        $this->filesystem->putFileContents($filepath, $code);

        $this->io->writeln(sprintf(
                "\n<info>Method <value>%s::%s()</value> has been created.</info>",
                $resource->getSrcClassname(), $name
            ), 2);
    }
766816
public function setConnectionResource($resource): void
    {
        foreach ($this->items as $converter) {
            if ($converter instanceof ConnectionAware) {
                $converter->setConnectionResource($resource);
            }
        }
    }
649691
public function apply($resource){
		// Format
		@list(,$width,$height,$keep_ratio)=func_get_args();
		// Get original resolution
		$w_src=imagesx($resource);
		$h_src=imagesy($resource);
		if($w_src===false || $h_src===false){
			throw new Exception("An error was encountered while getting image resolution");
		}
		// Percent resize
		if(substr((string)$width,-1)=='%'){
			$percent=(float)substr($width,0,-1)/100;
			$width=round(imagesx($resource)*$percent);
			$height=round(imagesy($resource)*$percent);
		}
		// Manual resize
		else{
			$width=(int)$width;
			$height=(int)$height;
			if($keep_ratio===null){
				$keep_ratio=true;
			}
			else{
				$keep_ratio=(bool)$keep_ratio;
			}
			if($width<1){
				$width=1;
			}
			if($height<1){
				$height=1;
			}
			// Adapt resolution
			if($keep_ratio){
				if(($w_src/$width)>($h_src/$height)){
					$height=round(($width/$w_src)*$h_src);
				}
				else{
					$width=round(($height/$h_src)*$w_src);
				}
			}
		}
		// Create new image
		$image=$this->_createTrueColor($width,$height);
		// Resize
		if(!imagecopyresampled($image,$resource,0,0,0,0,$width,$height,$w_src,$h_src)){
			throw new Exception("Failed to resample image");
		}
		return $image;
	}
584037
private function setResources($resources)
    {
        if (!$resources instanceof ResourcesInterface) {
            $files = (array)$resources;
            $resources = new Resources;

            array_walk($files, [$resources, 'addFileResource']);
        }

        $this->resources = $resources;
    }
1045173
public function apply($resource){
		if(!function_exists('imagefilter')){
			throw new Exception("It seems your PHP version is not compiled with the bundled version of the GD library");
		}
		// Format
		@list(,$level)=func_get_args();
		$level=(int)$level;
		if($level<-255) $level=-255;
		if($level>255)  $level=255;
		// Apply effect
		if(!imagefilter($resource,IMG_FILTER_BRIGHTNESS,$level)){
			throw new Exception("BRIGHTNESS filter failed");
		}
		return $resource;
	}