1

i have a problem with resizing image in CI ( i'm new to CI by the way ). so here is my code :

    $config['image_library'] = 'gd2';
    $config['source_image'] = base_url()."/uploads/test.png";
    $config['maintain_ratio'] = TRUE;
    $config['width']         = 800;
    $config['height']       = 600;
    $config['new_image'] = base_url().'/uploads/resized.jpg';


    $this->load->library('image_lib');
    $this->image_lib->initialize($config);
    $this->image_lib->resize();

    echo $this->image_lib->display_errors();
    echo $config['source_image'];

it give me this error :

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

i'm using MAMP as a server and i see GD enabled on phpinfo. i also try to echo the image url , and yes its really there.

please help. Thanks

2
  • Instead of base_url(), try the absolute or relative path for once. Commented Sep 24, 2015 at 16:43
  • You can try with relative path, can also take a look here philonthe.net/2010/07/codeigniters-image-library Commented Sep 24, 2015 at 16:47

1 Answer 1

3

You have to use relative path and you can try with this one

$this->load->library('image_lib');
// Set your config up
$this->image_lib->initialize($config);
// Do your manipulation
$this->image_lib->clear();

Please see this one

Sign up to request clarification or add additional context in comments.

2 Comments

Hello!, Thanks for the answer. you see i already use initialization. so i try using a relative url, something like this (../uploads/test.png) right ? i also add "$this->image_lib->clear();" after "$this->image_lib->resize();" while now it doesn't give me an error but the image is not resized yet.
hey, i just change the source url to "./uploads/test.png" and it works, Thanks anyway ! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.