Marks a Image with Stamp Image.
@access		public
@param		string		$source 		File Name of Source Image
@param		string		$target 		Target Name of Target Image
@return		bool
4180
public function markImage( $source, $target = NULL )
	{
		if( !$target )
			$target = $source;
		
		$creator	= new UI_Image_Creator();
		$creator->loadImage( $source );
		$image		= $creator->getResource();
		$type		= $creator->getType();

		$position		= $this->calculatePosition( $creator );
		$stampHeight	= $this->stamp->getHeight();
		$stampWidth		= $this->stamp->getWidth();
		$stampResource	= $this->stamp->getResource();
		imagecopymerge( $image, $stampResource, $position['x'], $position['y'], 0, 0, $stampWidth, $stampHeight, $this->alpha );

		$printer	= new UI_Image_Printer( $image );
		$printer->save( $target, $type );
	}
599346
public function thumbnail(&$source, $target, array $action)
    {
        list($width, $height) = $action['value'];

        if ($this->image->set($source)->thumbnail($width, $height)->save($target)) {
            $source = $target;
            return true;
        }

        return false;
    }
1369864
public function copyFiles($source, $target, $files)
    {
        foreach ($files as $file) {
            $this->copyFile($source, $target, $file);
        }
    }
364819
public function copyDirs($source, $target, $dirs)
    {
        foreach ($dirs as $dir) {
            $this->copyDir($source, $target, $dir);
        }
    }
1097431
public function copy($source, $target)
    {
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);

        if (!file_exists($target)) {
            mkdir($target, 0777, true);
        }

        foreach ($ri as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
            if ($file->isDir()) {
                if (!file_exists($targetPath)) {
                    mkdir($targetPath);
                }
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
378285
protected function copyDirectory($source, $target)
    {
        new Rah_Eien_Action_Stat($source, 'rd');
        new Rah_Eien_Action_Stat($target, 'wd');

        $files = new RecursiveDirectoryIterator($source);
        $file = new RecursiveIteratorIterator($files, RecursiveIteratorIterator::SELF_FIRST);

        while ($file->valid())
        {
            if ($file->isDot() === false)
            {
                $name = $target.'/'.$file->getSubPathName();

                if ($file->isDir())
                {
                    if (@mkdir($name) === false)
                    {
                        throw new Rah_Eien_Exception('Unable to create a directory: '.$name);
                    }
                }
                else
                {
                    $this->copyFile($file->getPathname(), $name);
                }
            }

            $file->next();
        }
    }
602267
private function mergeUnmodifiedPartial(array &$target, array $source)
    {
        foreach ($source as $key => $value) {
            if (is_array($value) && isset($target[$key])) {
                $this->mergeUnmodifiedPartial($target[$key], $value);
            } else {
                $target[$key] = $value;
            }
        }
    }
102265
protected function _copyDirectory($source, $target)
    {
        $result = false;

        if (!is_dir($target)) {
            $result = mkdir($target, 0755, true);
        }
        else
        {
            // Clear directory
            $iter = new \RecursiveDirectoryIterator($target);
            foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f)
            {
                if ($f->isDir())
                {
                    if (!in_array($f->getFilename(), array('.', '..'))) {
                        rmdir($f->getPathname());
                    }
                } else {
                    unlink($f->getPathname());
                }
            }
        }

        if (is_dir($target))
        {
            $result = true; // needed for empty directories
            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
            foreach ($iterator as $f)
            {
                if ($f->isDir()) {
                    $path = $target.'/'.$iterator->getSubPathName();
                    if (!is_dir($path)) {
                        $result = mkdir($path);
                    }
                } else {
                    $result = copy($f, $target.'/'.$iterator->getSubPathName());
                }

                if ($result === false) {
                    break;
                }
            }
        }

        return $result;
    }
858285
private function _copySection($source, &$target)
    {
        foreach ($source as $key => $value) {

            if (!array_key_exists($key, $target)) $target[$key] = $value;
        }
    }
108645
public function write($source, string $target): void
    {
        $source->move(\dirname($target), basename($target));
    }
958923
private function deep_copy($source, $target_path)
    {
        // Loop through $source dir.
        $contents = \scandir($source);

        if (empty($contents)) {
            return;
        }

        foreach ($contents as $file) {
            if ('.' === $file || '..' === $file) {
                continue;
            }

            $src_path = \trailingslashit($source) . $file;
            $new_path = \trailingslashit($target_path) . $file;

            if (\is_dir($src_path)) {
                $this->mkdir($new_path);
                $this->deep_copy($src_path, $new_path);
                continue;
            }

            if ($this->file->copy($src_path, $new_path, $this->force)) {
                $this->copied[] = $new_path;
            }
        }
    }
275314
protected function copy($source, $target)
    {
        if (is_file($source)) {
            $exists = is_file($target) ? true :false;
            $this->filesystem->copy($source, $target);

            if (!$exists) {
                return true;
            }
        }

        return false;
    }
158175
private function copyRecursive($source, $target)
    {
        if (!is_dir($source)) {
            $this->filesystem->ensureDirectoryExists(dirname($target));
            copy($source, $target);

            return;
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $this->filesystem->ensureDirectoryExists($target);

        foreach ($iterator as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
1010095
public function compress($source, $target = '')
    {
        $target = $target ?: $source.'.gz';
        $fh = @fopen($source, 'rb');
        $gz = @gzopen($target, 'wb9');

        if ($fh === false || $gz === false) {
            return false;
        }

        while (!feof($fh)) {
            if (gzwrite($gz, fread($fh, 1024)) === false) {
                return false;
            }
        }

        fclose($fh);
        gzclose($gz);

        return true;
    }
885429
public function detectCrossAge($source, $target)
    {
        $source_image = self::encode($source);
        $target_image = self::encode($target);

        return Request::exec(self::DETECT_CROSS_AGE, compact('source_image', 'target_image'));
    }
957042
public function createImagesFromVideos($source, $target = 'step-%03d.jpg')
    {
        try {
            $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);

            $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
            ->addPreInputCommand('-y')
            ->addCommand('-i', $source)
            ->setOutputPath($target)
            ->execute();
        } catch (FfmpegProcessOutputException $e) {
            throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos');
        } catch (\PHPVideoToolkit\Exception $e) {
            throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos');
        }

        return $target;
    }
1116247
protected function copyFile($source, $target)
    {
        new Rah_Eien_Action_Stat($source, 'rf');

        if (file_exists($target))
        {
            new Rah_Eien_Action_Stat($target, 'wf');
        }

        if ($in = fopen($source, 'rb'))
        {
            if ($out = fopen($target, 'wb'))
            {
                flock($out, LOCK_EX);
                flock($in, LOCK_EX);

                while (!feof($in))
                {
                    fwrite($out, fread($in, 512));
                }

                flock($in, LOCK_UN);
                flock($out, LOCK_UN);
                fclose($out);
            }

            fclose($in);
        }
        else
        {
            throw new Rah_Eien_Action_Exception('Unable to copy "'.$source.'" to "'.$target.'".');
        }
    }