[eluser]Bramme[/eluser]
Hey all. I've come across a weird problem.
I'm looping through a directory of images and checking if there's a corresponding thumbnail with this code:
Code:
function check_thumbnails() {
foreach ($this->folders as $folder) {
$dir = $this->main_dir.$folder;
foreach (glob($dir.'/*') as $file) {
$ext = strtolower(substr($file, strrpos($file, '.') + 1));
if (in_array($ext, $this->image_types)) {
$image = substr($file, strrpos($file, '/') + 1);
if ( ! file_exists($this->main_dir.$folder.'/'.$this->thumb_folder_name.'/'.$image)) {
$this->create_thumb($folder, $image);
}
}
}
}
}
This works like a charm, however, the problem lies with my create_thumb method:
Code:
function create_thumb($folder, $image) {
$dir = $_SERVER['DOCUMENT_ROOT'].'gallery/'.$this->main_dir;
$source = $dir.$folder.'/'.$image;
$new = $dir.$folder.'/'.$this->thumb_folder_name.'/'.$image;
$config['image_library'] = 'gd2';
$config['source_image'] = $source;
$config['new_image'] = $new;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['master_dim'] = 'width';
$config['width'] = $this->thumb_width;
$config['height'] = 50;
$this->CI->load->library('image_lib', $config);
if ( ! $this->CI->image_lib->resize()) {
echo $this->CI->image_lib->display_errors();
}
$this->CI->image_lib->clear();
}
2 images get resized, but then I just get a lot of "Your server does not support the GD function required to process this type of image." errors.
I first thought it'd be a memory problem, but "memory_limit" in php.ini is set to 128M...