Welcome Guest, Not a member yet? Register   Sign In
Image resizing in loop.
#1

[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...


Messages In This Thread
Image resizing in loop. - by El Forum - 09-07-2008, 06:57 AM
Image resizing in loop. - by El Forum - 09-07-2008, 08:23 AM
Image resizing in loop. - by El Forum - 09-07-2008, 08:30 AM
Image resizing in loop. - by El Forum - 09-07-2008, 09:34 AM
Image resizing in loop. - by El Forum - 09-07-2008, 10:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB