I have wrote a system for my personal website with CodeIgniter and used GD2 library to manipulate images according to my needs. It worked just fine when on localhost and a free hosting that I used for testing. But now that I am on a paid hosting from a different provider, It doesn't work for the jpg files. It shows the broken-image icon. But works just fine with PNG files. I have tried displaying the manipulation errors but nothing was displayed.
Here is my media controller, which manipulates the images;
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Media extends CI_Controller
{
function sandbox($imageName , $width)
{
if(!is_file('uploads/sandbox/'.$width.'-'.$imageName)) {
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/original/'.$imageName;
$config['new_image'] = 'uploads/sandbox/'.$width.'-'.$imageName;
$config['dynamic_output'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['master_dim'] = 'width';
$config['width'] = $width;
$config['height'] = $width;
$this->image_lib->initialize($config);
return $this->image_lib->resize();
} else {
return true;
}
}
public function covers($imageName)
{
if($this->sandbox($imageName, 920)) {
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/sandbox/'.'920-'.$imageName;
$config['dynamic_output'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['width'] = 920;
$config['height'] = 450;
$this->image_lib->initialize($config);
$this->image_lib->crop();
}
}
public function images($imageName)
{
if($this->sandbox($imageName, 440)) {
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/sandbox/'.'440-'.$imageName;
$config['dynamic_output'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['width'] = 440;
$config['height'] = 300;
$this->image_lib->initialize($config);
if(!$this->image_lib->crop()){
echo $this->image_lib->display_errors();
}
}
}
public function facebook($imageName)
{
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/original/'.$imageName;
$config['dynamic_output'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['width'] = 256;
$config['height'] = 256;
$this->image_lib->initialize($config);
echo $this->image_lib->resize();
}
}