Welcome Guest, Not a member yet? Register   Sign In
image_lib and gd
#1

[eluser]DavidBer[/eluser]
Please take it a little easy on me Smile To use the old radio line, "First time caller, long time listener."

I am trying to do a simple thumbnail generation.

Here is the code:
Code:
$config['image_library'] = 'gd2';
        $config['source_image']    = '../application/content/chris.jpg';
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width']     = 75;
        $config['height']    = 50;

        //Load up the library
        $this->load->library('image_lib', $config);

        //now resize it.
        if ( ! $this->image_lib->resize())
        {
            echo $this->image_lib->display_errors('<p>', '</p>');
        }

I am getting this result:
Code:
The path to the image is not correct.

Your server does not support the GD function required to process this type of image.

So to make sure I was not as dumb as I thought I was, I created a quick controller to load up a view.
Code:
<img src="../application/content/chris.jpg" >

I get the image on the screen.

So I figured I would check and make sure that GD was installed and this is the result.

Code:
GD Support    enabled
GD Version    bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.3.7
GIF Read Support    enabled
GIF Create Support    enabled
JPG Support    enabled
PNG Support    enabled
WBMP Support    enabled
XBM Support    enabled

I have searched the forums and have not found an answer. I have tested this on a local mac running mamp, and two unix boxes.

Can someone please point me in the right direction.

Thanks.
#2

[eluser]DavidBer[/eluser]
After pulling my hair out testing this with 1.7.2 and 2.0 betas. I figured it had to be something wrong on my end. So I tried it on XAMMP instead of MAMP. Same results. Then somehow a brain fart occurred and I thought it may be something regarding the path. Sure enough, it was path related.

It could not find the actual file. It seems that the path that is being passed does not work off the site based path but the server based path.

So a very simple change in the code and it works like a charm.

Code:
$config['source_image']    = $_SERVER["DOCUMENT_ROOT"].'/application/content/chris.jpg';




Theme © iAndrew 2016 - Forum software by © MyBB