@darrion.kuhn
To grayscale an image in CodeIgniter PHP, you can use the following steps:
$this->load->library('image_lib');
$config['image_library'] = 'gd2'; $config['source_image'] = 'path_to_your_image.jpg'; $config['new_image'] = 'path_to_save_grayscale_image.jpg'; $config['create_thumb'] = FALSE; $config['maintain_ratio'] = TRUE; $config['width'] = 300; // Set the width of the grayscale image $config['height'] = 200; // Set the height of the grayscale image $config['master_dim'] = 'auto'; $config['quality'] = 90;
$config['new_image'] = 'path_to_save_grayscale_image.jpg'; $config['create_thumb'] = FALSE; $config['maintain_ratio'] = TRUE; $config['width'] = 300; // Set the width of the grayscale image $config['height'] = 200; // Set the height of the grayscale image $config['master_dim'] = 'auto'; $config['quality'] = 90; $config['image_library'] = 'gd2'; $config['source_image'] = 'path_to_your_image.jpg'; $config['create_thumb'] = FALSE; $config['maintain_ratio'] = TRUE; $config['width'] = 300; // Set the width of the grayscale image $config['height'] = 200; // Set the height of the grayscale image $config['master_dim'] = 'auto'; $config['quality'] = 90; $config['new_image'] = 'path_to_save_grayscale_image.jpg'; $config['maintain_ratio'] = TRUE;
$this->image_lib->initialize($config); $this->image_lib->greyscale();
if (!$this->image_lib->greyscale()) { echo $this->image_lib->display_errors(); } else { echo 'Image has been gray scaled successfully'; }
This code will load the image library in CodeIgniter, set the configuration options for the grayscale effect, apply the grayscale effect to the image, and then display any errors if the grayscale effect fails.