public function copy(string $targetPath, string $targetName = null, int $perms = 0644): bool
	{
		$targetPath = rtrim($targetPath, '/ ') . '/';

		$targetName = is_null($targetName) ? $this->getFilename() : $targetName;

		if (empty($targetName))
		{
			throw ImageException::forInvalidFile($targetName);
		}

		if (! is_dir($targetPath))
		{
			mkdir($targetName, 0755, true);
		}

		if (! copy($this->getPathname(), "{$targetPath}{$targetName}"))
		{
			throw ImageException::forCopyError($targetPath);
		}

		chmod("{$targetPath}/{$targetName}", $perms);

		return true;
	}
public function copy(string $targetPath, string $targetName = null, int $perms = 0644): bool
	{
		$targetPath = rtrim($targetPath, '/ ') . '/';

		$targetName = is_null($targetName) ? $this->getFilename() : $targetName;

		if (empty($targetName))
		{
			throw ImageException::forInvalidFile($targetName);
		}

		if (! is_dir($targetPath))
		{
			mkdir($targetName, 0755, true);
		}

		if (! copy($this->getPathname(), "{$targetPath}{$targetName}"))
		{
			throw ImageException::forCopyError($targetPath);
		}

		chmod("{$targetPath}/{$targetName}", $perms);

		return true;
	}
public function copy ( string $ targetPath , string $ targetName = null , int $ perms = 0644 ) : bool { $ targetPath = rtrim ( $ targetPath , '/ ' ) . '/' ; $ targetName = is_null ( $ targetName ) ? $ this -> getFilename ( ) : $ targetName ; if ( empty ( $ targetName ) ) { throw ImageException :: forInvalidFile ( $ targetName ) ; } if ( ! is_dir ( $ targetPath ) ) { mkdir ( $ targetName , 0755 , true ) ; } if ( ! copy ( $ this -> getPathname ( ) , "{$targetPath}{$targetName}" ) ) { throw ImageException :: forCopyError ( $ targetPath ) ; } chmod ( "{$targetPath}/{$targetName}" , $ perms ) ; return true ; }
Makes a copy of itself to the new location. If no filename is provided
it will use the existing filename.

@param string      $targetPath The directory to store the file in
@param string|null $targetName The new name of the copied file.
@param integer     $perms      File permissions to be applied after copy.

@return boolean
Makes a copy of itself to the new location . If no filename is provided it will use the existing filename .