This might go a little beyond tech support, but I thought I might ask.
My image hosting website is exclusively for gif images, so I'd like to automatically convert if someone uploads a jpg or png.
I tried writing the following to class.upload.php:
and the following to class.imageconvert.php:
It uploads the image, but then returns an error and doesn't actually save the finished file to the images directory.
Instead, in the image directory, I get temporary files like this:
http://demo.chevereto.com/images/LgVwb.png
Any tips for how I might accomplish converting files to gif?
Thanks
My image hosting website is exclusively for gif images, so I'd like to automatically convert if someone uploads a jpg or png.
I tried writing the following to class.upload.php:
Code:
public function process()
{
if($this->valid_data()) {
$this->extension = $this->get_true_extension($this->mime);
if($this->extension == 'jpg') {
require_once('class.imageconvert.php');
$this->ImageConvert = new ImageConvert($this->working, $this->extension, $this->img_upload_path.'temp_'.generateRandomString(256));
unset($this->working); unset($this->extension);
$this->working = $this->ImageConvert->out;
$this->extension = 'gif';
}
and the following to class.imageconvert.php:
Code:
class ImageConvert {
function __construct($file, $extension, $destination)
{
if($extension=='jpg') {
$temp_image = $this->ImageCreateFromjpeg($file);
unlink($file);
// Now we convert gd to png
imagegif($temp_image, $destination);
$this->out = $destination;
}
}
It uploads the image, but then returns an error and doesn't actually save the finished file to the images directory.
Instead, in the image directory, I get temporary files like this:
http://demo.chevereto.com/images/LgVwb.png
Any tips for how I might accomplish converting files to gif?
Thanks