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.
#2

[eluser]Sumon[/eluser]
is the folder $folder have 0777 permission?
#3

[eluser]Bramme[/eluser]
It's on localhost, so I'd be guessing yes... Besides, if you're using dynamic output, I wouldn't know why I'd have to have my folder chmodded.
#4

[eluser]Sumon[/eluser]
Without having chomd 0777 i am not sure resized thumbnail create or not in server because resized image itself a file and need a place to save itself. No doubt it will work fine in localhost.
#5

[eluser]Bramme[/eluser]
The whole point of dynamically outputting the image is that it doesn't have to be saved. It just sits in memory (as far as I know).

And I seriously doubt it works on localhost as it ISN'T working right now...
#6

[eluser]Bramme[/eluser]
Anybody else got an idea?




Theme © iAndrew 2016 - Forum software by © MyBB