traits/image.php
final public function saveImage($filename)
	{
		$extension = pathinfo($filename, PATHINFO_EXTENSION);

		if (! is_string($extension)) {
			$extension = image_type_to_extension($this->_image_type);
			$filename .= ".{$extension}";
		}

		switch(strtolower($extension))
		{
			case 'jpeg':
			case 'jpg':
				return $this->imageJPEG($filename);
				break;

			case 'png':
				return $this->imagePNG($filename);
				break;

			case 'gif':
				return $this->imageGIF($filename);

			default:
				trigger_error('Invalid extension or not an image', E_USER_WARNING);
				return false;
		}
	}
final public function saveImage($filename)
	{
		$extension = pathinfo($filename, PATHINFO_EXTENSION);

		if (! is_string($extension)) {
			$extension = image_type_to_extension($this->_image_type);
			$filename .= ".{$extension}";
		}

		switch(strtolower($extension))
		{
			case 'jpeg':
			case 'jpg':
				return $this->imageJPEG($filename);
				break;

			case 'png':
				return $this->imagePNG($filename);
				break;

			case 'gif':
				return $this->imageGIF($filename);

			default:
				trigger_error('Invalid extension or not an image', E_USER_WARNING);
				return false;
		}
	}
final public function saveImage ( $ filename ) { $ extension = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; if ( ! is_string ( $ extension ) ) { $ extension = image_type_to_extension ( $ this -> _image_type ) ; $ filename .= ".{$extension}" ; } switch ( strtolower ( $ extension ) ) { case 'jpeg' : case 'jpg' : return $ this -> imageJPEG ( $ filename ) ; break ; case 'png' : return $ this -> imagePNG ( $ filename ) ; break ; case 'gif' : return $ this -> imageGIF ( $ filename ) ; default : trigger_error ( 'Invalid extension or not an image' , E_USER_WARNING ) ; return false ; } }
Generic save funciton, which converts image according to extension

@param string $filename Path and extension to save to
@return bool            Success or failure of save
Generic save funciton which converts image according to extension