src/UI/Image.php
public function save( $fileName = NULL, $type = NULL )
	{
		if( !$type )
			$type	= $this->type;
		if( !$fileName )
			$fileName	= $this->fileName;
		if( !$fileName )
			throw new RuntimeException( 'No image file name set' );
		switch( $type )
		{
			case IMAGETYPE_GIF:
				return imagegif( $this->resource, $fileName );
			case IMAGETYPE_JPEG:
				return imagejpeg( $this->resource, $fileName, $this->quality );
			case IMAGETYPE_PNG:
				return imagepng( $this->resource, $fileName );
			default:
				throw new Exception( 'Image type "'.$type.'" is no supported' );
		}
		if( $fileName === $this->fileName )															//  if saved to same file
			$this->load( $this->fileName );															//  reload image
	}
public function save( $fileName = NULL, $type = NULL )
	{
		if( !$type )
			$type	= $this->type;
		if( !$fileName )
			$fileName	= $this->fileName;
		if( !$fileName )
			throw new RuntimeException( 'No image file name set' );
		switch( $type )
		{
			case IMAGETYPE_GIF:
				return imagegif( $this->resource, $fileName );
			case IMAGETYPE_JPEG:
				return imagejpeg( $this->resource, $fileName, $this->quality );
			case IMAGETYPE_PNG:
				return imagepng( $this->resource, $fileName );
			default:
				throw new Exception( 'Image type "'.$type.'" is no supported' );
		}
		if( $fileName === $this->fileName )															//  if saved to same file
			$this->load( $this->fileName );															//  reload image
	}
public function save ( $ fileName = NULL , $ type = NULL ) { if ( ! $ type ) $ type = $ this -> type ; if ( ! $ fileName ) $ fileName = $ this -> fileName ; if ( ! $ fileName ) throw new RuntimeException ( 'No image file name set' ) ; switch ( $ type ) { case IMAGETYPE_GIF : return imagegif ( $ this -> resource , $ fileName ) ; case IMAGETYPE_JPEG : return imagejpeg ( $ this -> resource , $ fileName , $ this -> quality ) ; case IMAGETYPE_PNG : return imagepng ( $ this -> resource , $ fileName ) ; default : throw new Exception ( 'Image type "' . $ type . '" is no supported' ) ; } if ( $ fileName === $ this -> fileName ) //  if saved to same file $ this -> load ( $ this -> fileName ) ; //  reload image }
Writes an image to file.
@access		public
@param		string		$fileName		Name of new image file
@param		integer		$type			Type of image (IMAGETYPE_GIF|IMAGETYPE_JPEG|IMAGETYPE_PNG)
@return		boolean
@throws		RuntimeException if neither file has been loaded before nor a file name is given
@throws		Exception if image type is not supported for writing
Writes an image to file .