src/Image.php
public function exportImage($keep_resource = false) {

		# export current resource image
		array_unshift($this->_output_options, $this->_image_resource, $this->_save_path);

		switch($this->_output_format) {
			case 'jpeg' :
			case 'jpg'  :
				if (!$this->_save_path) {
					header('content-type: image/jpeg');
				}

				$result = call_user_func_array('imagejpeg',  $this->_output_options);
				break;

			case 'png' :
				if (!$this->_save_path) {
					header('content-type: image/png');
				}

				$result = call_user_func_array('imagepng',  $this->_output_options);
				break;

			case 'gif' :
				if (!$this->_save_path) {
					header('content-type: image/gif');
				}

				$result = call_user_func_array('imagegif',  $this->_output_options);
				break;
		}

		// Reset output_options
		unset($this->_output_options[0], $this->_output_options[1]);
		$this->_output_options = array_values($this->_output_options);

		// Destroy Image
		if ($keep_resource === false) {
			$this->destroy();
		}

		// Exit incase of exporting to browser
		if (!$this->_save_path) {
			exit;
		}

		return ($result) ? ($this->_save_name  ? $this->_save_name : true) : false;
		# Method End
	}
public function exportImage($keep_resource = false) {

		# export current resource image
		array_unshift($this->_output_options, $this->_image_resource, $this->_save_path);

		switch($this->_output_format) {
			case 'jpeg' :
			case 'jpg'  :
				if (!$this->_save_path) {
					header('content-type: image/jpeg');
				}

				$result = call_user_func_array('imagejpeg',  $this->_output_options);
				break;

			case 'png' :
				if (!$this->_save_path) {
					header('content-type: image/png');
				}

				$result = call_user_func_array('imagepng',  $this->_output_options);
				break;

			case 'gif' :
				if (!$this->_save_path) {
					header('content-type: image/gif');
				}

				$result = call_user_func_array('imagegif',  $this->_output_options);
				break;
		}

		// Reset output_options
		unset($this->_output_options[0], $this->_output_options[1]);
		$this->_output_options = array_values($this->_output_options);

		// Destroy Image
		if ($keep_resource === false) {
			$this->destroy();
		}

		// Exit incase of exporting to browser
		if (!$this->_save_path) {
			exit;
		}

		return ($result) ? ($this->_save_name  ? $this->_save_name : true) : false;
		# Method End
	}
public function exportImage ( $ keep_resource = false ) { # export current resource image array_unshift ( $ this -> _output_options , $ this -> _image_resource , $ this -> _save_path ) ; switch ( $ this -> _output_format ) { case 'jpeg' : case 'jpg' : if ( ! $ this -> _save_path ) { header ( 'content-type: image/jpeg' ) ; } $ result = call_user_func_array ( 'imagejpeg' , $ this -> _output_options ) ; break ; case 'png' : if ( ! $ this -> _save_path ) { header ( 'content-type: image/png' ) ; } $ result = call_user_func_array ( 'imagepng' , $ this -> _output_options ) ; break ; case 'gif' : if ( ! $ this -> _save_path ) { header ( 'content-type: image/gif' ) ; } $ result = call_user_func_array ( 'imagegif' , $ this -> _output_options ) ; break ; } // Reset output_options unset ( $ this -> _output_options [ 0 ] , $ this -> _output_options [ 1 ] ) ; $ this -> _output_options = array_values ( $ this -> _output_options ) ; // Destroy Image if ( $ keep_resource === false ) { $ this -> destroy ( ) ; } // Exit incase of exporting to browser if ( ! $ this -> _save_path ) { exit ; } return ( $ result ) ? ( $ this -> _save_name ? $ this -> _save_name : true ) : false ; # Method End }
Save Or Output Current Image Resource
@return Boolean indicates to success or fail
@param  $keep_resource  Boolean  If To Not Destroy Resource After Exporting, Useful If Weneed to continue on image resource
Save Or Output Current Image Resource