Welcome Guest, Not a member yet? Register   Sign In
Problem with image lib and dynamic output
#1

[eluser]Bramme[/eluser]
Hey all,

I'm working on a little something but I've ran into a snag. I'm building an image gallery script but I want it to have the option of storing thumbnails or dynamically outputting them.

I made a function thumbnail in my controller, but it's not working...

Here's the function:
Code:
function thumbnail($folder = NULL, $image = NULL) {
    
    $this->config->load('galleries');
    
    if ( ! isset($folder) OR ! isset($image)) {
        return FALSE;
    }
    
    $config['image_library'] = 'gd2';
    $config['source_image'] = $this->config->item('main_dir').$folder.$image;
    $config['dynamic_output'] = TRUE;
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['master_dim'] = 'width';
    $config['width'] = $this->config->item('thumb_width');
    $config['height'] = 50;
    
    $this->load->library('image_lib', $config);
    
    $this->image_lib->resize();
    
}

However, when I visit http://example.com/gallery/thumbnail/tes...inside.jpg (gallery is my controller) I get a nice and shiny CI error 404. I'm guessing this has something to do with the uri path containing the .jpg extension.

Has anybody got any tips on how to implement dynamicly resized images?

edit: okay, I got a little confused, my ci folder was in a gallery folder and my controller is also called folder, so the url should be http://example.com/gallery/gallery/thumb...inside.jpg but this just gives me a white page...

Found out I had a typo in my source image path too... Updated code:
Code:
function thumbnail($folder = NULL, $image = NULL) {
    
    $this->config->load('galleries');
    
    if ( ! isset($folder) OR ! isset($image)) {
        return FALSE;
    }
    
    $url = base_url().$this->config->item('main_dir').$folder.'/'.$image;
    
    $config['image_library'] = 'gd2';
    $config['source_image'] = $url;
    $config['dynamic_output'] = TRUE;
    $config['create_thumb'] = FALSE;
    $config['maintain_ratio'] = TRUE;
    $config['master_dim'] = 'width';
    $config['width'] = $this->config->item('thumb_width');
    $config['height'] = 50;
    
    $this->load->library('image_lib', $config);
    
    $this->image_lib->resize();
    
}
The url is correct, if I echo it and follow it, I get my image. However, when I access the controller, I get nothing but a white page.


Messages In This Thread
Problem with image lib and dynamic output - by El Forum - 09-07-2008, 04:30 AM
Problem with image lib and dynamic output - by El Forum - 09-07-2008, 05:14 AM
Problem with image lib and dynamic output - by El Forum - 09-07-2008, 05:21 AM
Problem with image lib and dynamic output - by El Forum - 09-07-2008, 05:50 AM
Problem with image lib and dynamic output - by El Forum - 09-07-2008, 06:25 AM
Problem with image lib and dynamic output - by El Forum - 09-08-2008, 12:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB