Welcome Guest, Not a member yet? Register   Sign In
Can't create thumbs using Image Manipulation class
#1

[eluser]chitoso[/eluser]
Hi all, I've been reading the docs and trying everything to make thumbs out of uploaded images but I can't seem to find the problem.

Images are uploaded and saved correctly but thumbs are not, it fails with no error output.
This is the code I'm using:

Code:
$data = $this->upload->data();

$config_image['image_library'] = 'gd';
$config_image['source_image'] = $data['full_path'];
$config_image['new_image'] = 'uploads/thumbs/';
$config_image['create_thumb'] = TRUE;
$config_image['maintain_ratio'] = TRUE;
$config_image['width'] = 750;
$this->load->library('image_lib', $config_image);

if ( !$this->image_lib->resize())
{
    $this->session->set_flashdata('message',  $this->image_lib->display_errors());
}


Also, I want to resize images to fit max-width=750, but maintain the ratio. Is what I'm doing correct to achive that?
Thanks in advance!
#2

[eluser]chitoso[/eluser]
Hey all, I've succesfully developed my first project with CI and I'm really happy with it.
One minor problem though, I've come across this issue again and I can't really get around it.

Does anyone have a clue on this matter?

I'd rather manage this using CI and not an external script like timthumb.
Thanks.
#3

[eluser]dstegelman[/eluser]
You need to set the config var ['new_image'] to an actual file, not just the directory. Also that directory needs to be absolute/relative server path.
#4

[eluser]chitoso[/eluser]
rom what I've seen in the docs (http://ellislab.com/codeigniter/user-gui...e_lib.html):
"If only the path is specified, the new image will be placed in the destination with the same name as the original.", so I assume this code should work.

Code:
$config_image['image_library'] = 'gd';
$config_image['source_image'] = $data['full_path'];
$config_image['new_image'] = 'uploads/proyectos/thumbs/';
$config_image['create_thumb'] = TRUE;
$config_image['maintain_ratio'] = TRUE;
$config_image['width'] = 120;

$this->load->library('image_lib', $config_image);

if (!$this->image_lib->resize()) {
    $this->session->set_flashdata('message', $this->image_lib->display_errors());
}

The weird thing is that it fails silently, no errors whatsoever. Any clues?
#5

[eluser]dstegelman[/eluser]
Thats really strange that there are no errors in the log or coming from display_errors().

Have you checked permissions?

It appears otherwise that you are doing it by the book so without any more info I can't really think of anything that would solve your issue.
#6

[eluser]chitoso[/eluser]
Thanks anyway. If I get around it I'll make sure to post it Smile For now, timthumb it is.
#7

[eluser]chitoso[/eluser]
Hi all,
I hate to revive this thread, but I'm constantly facing this problem in CI and it's really frustrating me Sad

Does anyone have a clue on why this might be happening or at least some help to troubleshoot this?

Thanks a million.
#8

[eluser]andyy[/eluser]
Try this for testing purposes:
Code:
// replace this...
if (!$this->image_lib->resize()) {
    $this->session->set_flashdata('message', $this->image_lib->display_errors());
}

// with this..
$this->image_lib->display_errors();

If you still get nothing ensure that the image is passing properly from the form. Maybe map a static test image from your folder and see if you're generating a thumbnail like that with your script.
#9

[eluser]chitoso[/eluser]
I've followed both your recommendations but it just fails silently.




Theme © iAndrew 2016 - Forum software by © MyBB