/** * Saves the image to disk * * @param \SplFileInfo $file the filename of the new image. Leave null with overwrite = false to automatically create a new file with the .copy pre-extension. the .copy file will be overwritten on next change... * @param string $aOverwrite wether or not to overwrite the file * * @return \imagemanipulation\ImageBuilder $this for chaining */ public function save(\SplFileInfo $file = null, $aOverwrite = false) { $search = "." . $this->file->getExtension(); if ($file === null && $aOverwrite === false && !strstr($this->file->getPathname(), '.copy' . $search)) { $file = new \SplFileInfo(str_replace($search, ".copy" . $search, $this->file->getPathname())); } else { if ($file === null) { $file = $this->file; } } $this->applyFilters(); $this->res->setIsOverwrite($aOverwrite); $this->res->setOutputPath($file); $this->res->createImage(); return $this; }
/** * * @param $aFile \SplFileInfo The orifinal image file * @param $aIdentifier string The identifier to use for caching purposes * * @return \imagemanipulation\ImageImageResource */ public function getImageRes(\SplFileInfo $aFile, $identifier) { $folder = get_called_class(); $folder = str_replace("::", "", $folder); $folder = str_replace("\\", "", $folder); $cacheDir = $this->getCacheDir(); if (strstr($identifier, "::")) { $expl = explode("::", $identifier); $identifier = $expl[1]; } $dir = $cacheDir . DIRECTORY_SEPARATOR . $folder; if (!is_dir($dir)) { mkdir($dir); } $testFile = new \SplFileInfo($dir . DIRECTORY_SEPARATOR . $identifier . "." . $aFile->getExtension()); if ($testFile->isFile()) { $path = $testFile->getPathname(); unset($path); } $res = new ImageImageResource($aFile); $res->setOutputPath($testFile); return $res; }
/** * * @param $aFile \SplFileInfo The orifinal image file * @param $aIdentifier string The identifier to use for caching purposes * * @return \imagemanipulation\ImageImageResource */ public function getImageRes(\SplFileInfo $aFile, $aIdentifier) { $aIdentifier = str_replace("::", "", $aIdentifier); $aIdentifier = str_replace("\\", "", $aIdentifier); $cacheDir = $this->getCacheDir(); $testFile = new \SplFileInfo($cacheDir . DIRECTORY_SEPARATOR . $aIdentifier . '-' . $aFile->getFilename()); if ($testFile->isFile()) { $path = $testFile->getPathname(); unset($path); } $res = new ImageImageResource($aFile); $res->setOutputPath($testFile); return $res; }