Search code examples
codeigniterpngjpegimagelibrary

Using codeigniter image lib - converting images


Using codeigniter image lib is it possible to just change an image type? Trying to convert from * -> PNG.

The below doesn't work!

$config = array();
$config['source_image']='uploads/'.$name.'.'.$m[1];
$config['new_image']='uploads/'.$name.'.'.$png;
$objImage = new CI_Image_lib($config);

Many thanks! All help very appreciated!


Currently just using, but would like to use image lib and support all image types.

$sourceImage = imagecreatefromjpeg('uploads/'.$name.'.'.$m[1]);
imagepng($sourceImage, 'uploads/'.$name.'.png');

Solution

  • I think that you have to use ImageMagick

    $config['image_library'] = 'ImageMagick';
    $config['library_path']='/usr/bin';
    $config['source_image']='uploads/'.$name.'.'.$m[1];
    $config['new_image']='uploads/'.$name.'.'.$png;
    $objImage = new CI_Image_lib($config);