@param string $file
@param int    $offsetX
@param int    $offsetY
@param float  $opacity

@return static
354771
public function do_watermark($file, $offsetX = 0, $offsetY = 0, $opacity = 1.0)
    {
        return $this->_handler->do_watermark($file, $offsetX, $offsetY, $opacity);
    }
728826
public function getOverlayCanvas($file)
    {
        $canvas = new Canvas();
        $canvas->fromFile(Util::getResourcePath('Preset/'.$file));

        return $canvas;
    }
606829
public function setFile($file): self
    {
        $this->file = $file;

        if (is_string($file)) {
            $this->pathToFile = $file;
            $this->setFileName(pathinfo($file, PATHINFO_BASENAME));
            $this->mediaName = pathinfo($file, PATHINFO_FILENAME);

            return $this;
        }

        if ($file instanceof UploadedFile) {
            $this->pathToFile = $file->getPath().'/'.$file->getFilename();
            $this->setFileName($file->getClientOriginalName());
            $this->mediaName = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);

            return $this;
        }

        if ($file instanceof SymfonyFile) {
            $this->pathToFile = $file->getPath().'/'.$file->getFilename();
            $this->setFileName(pathinfo($file->getFilename(), PATHINFO_BASENAME));
            $this->mediaName = pathinfo($file->getFilename(), PATHINFO_FILENAME);

            return $this;
        }

        throw UnknownType::create();
    }
460976
public function watermark($opacity = 30) 
	{
		// This means that user didn't explicitly call it, use config instead
	    $watermarkInfo = $this->getWatermarkInfo();
		if(null === $watermarkInfo) {
			$this->openWatermark();
		}
		
        // New height and width for the watermark and coords where to place it
        list($resizedWatermarkWidth, $resizedWatermarkHeight, $destX, $destY) = 
        	$this->watermarkDimensionCoords();
        
        // Creation of the temporary watermark for this image
        $watermarkTmpFile = $this->getWatermarkTmpDir() . 
        	"tempWatermark_" . md5(uniqid()) . "." . 
        	$watermarkInfo['extension'];
        
        // This must stay here to ensure that the watermark is the current resource of thumbnailer service
        $this->openWatermark();
        $this->thumbnailerService->resize($resizedWatermarkWidth, $resizedWatermarkHeight);
        $this->thumbnailerService->save($watermarkTmpFile);
        
        // We open the temporary watermark image and the image to watermark using GD libraries
        $watermark = imagecreatefromgif($watermarkTmpFile);
        
        // Creazione del nuovo file immagine
        $imageInfo = $this->getImageInfo();
        switch ($imageInfo['extension']) {
		case 'png':
			$image = @imagecreatefrompng($this->getImageFullPath());
			break;
        
		case 'jpg':
			$image = @imagecreatefromjpeg($this->getImageFullPath());
			break;
        
		case 'gif':
			$image = @imagecreatefromgif($this->getImageFullPath());
			break;
        
		default:
			throw new \RuntimeException('Not supported image type');
			break;
        }
        
        // This is where the watermarking happens
        imagecopymerge(
        	$image, $watermark, $destX, 
        	$destY, 0, 0, $resizedWatermarkWidth, 
        	$resizedWatermarkHeight, $opacity
       	);
        
        switch ($imageInfo['extension']) {
		case 'png':
			$watermarkedImage = @imagepng($image, $this->getImageFullPath(), 0, null); // Corrupted image if NULL fourth parameter omitted!
			break;
        
		case 'jpg':
			$watermarkedImage = @imagejpeg($image, $this->getImageFullPath(), 100);
			break;
        
		case 'gif':
			$watermarkedImage = @imagegif($image, $this->getImageFullPath(), 100);
			break;
        }
        
        // Destruction of the images from memory
        @imagedestroy($watermark);
        @imagedestroy($image);
        
        return $watermarkedImage;
	}
963399
public function load($file,$ttl = 0)
	{
		$this->reset();
		$cache = \Cache::instance();
		$this->file = $file;
		$this->changed = false;
		$this->ttl = $ttl;
		$cacheHash = $this->getCacheHash($file);
		if ($this->f3->get('CACHE') && $ttl && ($cached = $cache->exists(
			$cacheHash,$content)) && $cached[0] + $ttl > microtime(TRUE)
		) {
			// load from cache
			$this->content = $content;
			$this->meta = $this->metaHandle->load($file,$ttl);
		} elseif ($this->fs->exists($file)) {
			// load from FS
			$this->meta = $this->metaHandle->load($file,$ttl);
			// if caching is on, save content to cache backend, otherwise it gets lazy loaded
			if ($this->f3->get('CACHE') && $ttl) {
				$this->content = $this->fs->read($file);
				$cache->set($cacheHash, $this->content, $ttl);
			}
		}
	}
358426
public function setFile($file, $contentDisposition = null, $autoLastModified = true)
    {
        $this->file = $file;

        if ($autoLastModified) {
            $this->setAutoLastModified();
        }

        if ($contentDisposition) {
            $this->setContentDisposition($contentDisposition);
        }

        return $this;
    }
1297628
public function OffsetSet ($index = 0, $path = '', $media = 'all', $renderPhpTags = FALSE, $doNotMinify = FALSE) {
		$item = $this->_completeItem($path, $media, $renderPhpTags, $doNotMinify);
		$currentGroupRecords = & $this->_getLinksGroupContainer($this->actualGroupName);
		$newItems = [];
		$added = FALSE;
		foreach ($currentGroupRecords as $key => $groupItem) {
			if ($key == $index) {
				$newItems[] = $item;
				$added = TRUE;
			}
			$newItems[] = $groupItem;
		}
		if (!$added) $newItems[] = $item;
		self::$linksGroupContainer[$this->getCtrlActionKey()][$this->actualGroupName] = $newItems;
		return $this;
	}
1295942
public function offsetSet($offset, $item) {

      if (is_null($offset)) {
        $this->append($item);
      } else {
        $this->validateIndex($offset);
        $this->items[$offset] = $item;
      }

      return $this;
    }
366838
function set_opacity($opacity, $mode = "Normal") {
		//Helpers::dompdf_debug("trace", "($opacity, $mode)");
		$this->_set_line_transparency($mode, $opacity);
		$this->_set_fill_transparency($mode, $opacity);
	}
913995
public static function highlight($file)
    {
        $highlightFileFunc = new \ReflectionFunction('highlight_file');
        if (!$highlightFileFunc->isDisabled()) {
            highlight_file($file);
        } else {
            echo '<pre>' . htmlspecialchars(file_get_contents($file)) . '</pre>';
        }
    }
687921
public function appendStream($source, $offset = 0)
    {
        $chunkFile = $this->chunkFile();
        $this->files->appendStream($chunkFile, $source, (int) $offset);

        return $this;
    }
1327121
public static InputStream streamFile(final File file, final long offset) throws IOException
  {
    final RandomAccessFile raf = new RandomAccessFile(file, "r");
    final long rafLength = raf.length();
    if (offset > 0) {
      raf.seek(offset);
    } else if (offset < 0 && offset < rafLength) {
      raf.seek(Math.max(0, rafLength + offset));
    }
    return Channels.newInputStream(raf.getChannel());
  }
422066
public static function forge($file = null, $data = null, $auto_encode = null)
	{
		$class = null;

		if ($file !== null)
		{
			$extension = pathinfo($file, PATHINFO_EXTENSION);

			$class = \Config::get('parser.extensions.'.$extension, null);
		}

		if ($class === null)
		{
			$class = get_called_class();
		}

		// Only get rid of the extension if it is not an absolute file path
		if ($file !== null and $file[0] !== '/' and $file[1] !== ':')
		{
			$file = $extension ? preg_replace('/\.'.preg_quote($extension).'$/i', '', $file) : $file;
		}

		// Class can be an array config
		if (is_array($class))
		{
			$class['extension'] and $extension = $class['extension'];
			$class = $class['class'];
		}

		// Include necessary files
		foreach ((array) \Config::get('parser.'.$class.'.include', array()) as $include)
		{
			if ( ! array_key_exists($include, static::$loaded_files))
			{
				require $include;
				static::$loaded_files[$include] = true;
			}
		}

		// Instantiate the Parser class without auto-loading the view file
		if ($auto_encode === null)
		{
			$auto_encode = \Config::get('parser.'.$class.'.auto_encode', null);
		}

		$view = new $class(null, $data, $auto_encode);

		if ($file !== null)
		{
			// Set extension when given
			$extension and $view->extension = $extension;

			// Load the view file
			$view->set_filename($file);
		}

		return $view;
	}
732168
public function offset($offset)
    {
        if(!empty($offset))
            $this->selectParams[self::OFFSET] = $offset;
        return $this;
    }
1363685
public function offset($offset = 0)
	{
		if ($this->offset === null)
		{
			$this->offset = new QueryElement('OFFSET', (int) $offset);
		}

		return $this;
	}
149519
static public function read($file) {
		if (! $file instanceof FileInterface) {
			$file = new File($file);
		}
		
		return static::parse($file->getContent());
	}
1217692
public function do_watermark($file, $offsetX = 0, $offsetY = 0, $opacity = 1.0)
    {
        $file = $this->alias->resolve($file);

        list($maskWidth, $maskHeight, $maskType) = getimagesize($file);

        if ($maskType === IMAGETYPE_GIF) {
            $maskImage = imagecreatefromgif($file);
        } elseif ($maskType === IMAGETYPE_JPEG) {
            $maskImage = imagecreatefromjpeg($file);
        } elseif ($maskType === IMAGETYPE_PNG) {
            $maskImage = imagecreatefrompng($file);
        } else {
            throw new PreconditionException('Installed GD does not support such images');
        }

        imagesavealpha($maskImage, true);

        $image = imagecreatetruecolor($this->_width, $this->_height);
        imagealphablending($image, false);
        imagesavealpha($image, true);
        if ($maskType !== IMAGETYPE_PNG) {
            $filedColor = imagecolorallocatealpha($image, 127, 127, 127, (1 - $opacity) * 127);
        } else {
            $filedColor = imagecolorallocate($image, 127, 127, 127);
        }

        imagelayereffect($maskImage, IMG_EFFECT_OVERLAY);
        imagefilledrectangle($maskImage, 0, 0, $maskWidth, $maskHeight, $filedColor);
        imagealphablending($this->_image, true);
        imagecopy($this->_image, $maskImage, $offsetX, $offsetY, 0, 0, $maskWidth, $maskHeight);

        return $this;
    }