CodeIgniter - Convert GIF to JPG? Possible?

codeigniter, imagemagick, php

Solution

For those interested in my solution, I simply used the built in GD PHP functions. I have little experience dealing with gif files so I was expecting this to be difficult. The fact of the matter is the CodeIgniter Image_lib and extended library (Which I never got to work properly) is overkill for this.

Here is what I used:

$image = imagecreatefromgif($path_to_gif_image);
imagejpeg($image, $output_path_with_jpg_extension);

Very easy and worked perfectly for what I needed.

Problem

I am looking to accomplish this in CodeIgniter specifically. The PHP App I am coding allows a user to upload either a jpg or an animated gif image. On the next step I want to allow the user to use jCrop to crop a few different size thumbnails. This would require me to convert a new copy of the animated gif to a jpg. My code works fine with uploaded jpg images, but creates a broken image for gif files. Is what I am trying to do possible? My Code: ``` // Create image to crop $config['image_library'] = 'ImageMagick'; $config['library_path'] = '/usr/bin'; $config['source_image'] = $this->config->item('upload_dir_path') . $file_path . 'original.' . $file_ext; chmod($config['source_image'], 0777); $config['new_image'] = $this->config->item('upload_dir_path') . $file_path . 'crop-me.jpg'; $this->image_lib->initialize($config); $this->image_lib->resize(); ```

Original source