Image Manipulation Problems

Hello All,
I am trying to use the image manipulation class to make thumbnails just after the raw images are uploaded, but I keep getting this error msg:
Unable to save the image. Please make sure the image and file directory are writable.

I have set the uploads folder permissions to 0777 but every image that is uploaded within this folder reverts to 644.

I am running Mac OSX10.5.7, My pathing seems correct and I am using both a local server with MAMP as well as account with Dreamhost.

I have tried chmod() function to no avail, I have set the uploads folder to inherit permissions to all included files (on mamp server), I am at my wit's end.

Any help is greatly appreciated.

my code is as follows:
//$img_path is from 'file_name' data from uploaded raw image
$thumb['image_library'] = 'gd2';
$thumb['source_image'] = './uploads_liquor/'.$img_path;
$thumb['new_image'] = './uploads/'.$img_path.'_thumb';
$thumb['create_thumb'] = TRUE;
$thumb['maintain_ratio'] = TRUE;
$thumb['width'] = 75;
$thumb['height'] = 50;


if ($this->image_lib->resize())
echo 'image resized';
echo $this->image_lib->display_errors();

I'm having the same problem. I'm attempting to copy the uploaded image to a new location with a new name before doing some other things with it. My file structure is


..and photos is fully 0777. This is the code I'm using (in /application/controllers/file.php):

function resize($filename, $target_name){
    $config['image_library']  ='gd2';
    $config['source_image'] = 'photos/uploads/'.$filename;
    $config['new_image'] = 'photos/live/'.$target_name;
    $config['width'] = '300';
    $config['height'] = '450';
    $config['maintain_ratio'] = TRUE;
    if(!$this->image_lib->resize()){ echo $this->image_lib->display_errors(); }

I've tried all of these with no success:

$config['new_image'] = '/photos/live/'.$target_name;
$config['new_image'] = './photos/live/'.$target_name;
$config['new_image'] = '/full/path/to/photos/live/'.$target_name;


"Unable to save the image. Please make sure the image and file directory are writable."

This looks like a bug in Image_lib.php (v1.7.1)

The documentation says you can enter a full path and file name for the config option "new_image".

In my case Image_lib.php is failing on line 1216 where imagejpeg() is trying to use the value of $full_dst_path. Where my values fed into the resize method were for example:

$config['source_image'] = "path/to/source/image/source_name.jpg";
$config['new_image'] = "different/path/to/new/image/new_name.jpg

The value of $full_dst_path was being put together (on line 264) as


using the following:

$this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;

I started a bug thread for this, but later discovered the problem. Looking at the OP's code, it looks like he also passed a file name without an extension, which Image_lib.php assumed to be a directory name despite the lack of a trailing slash.

Well done, Helmet!

This image manipulation problem has been a bit frustrating...

So, have you figured out a fix or do you reckon we will have to wait for a new version?

Thanks Again!

Just add a file extension to your new_image value, like:

$thumb[‘new_image’] = ‘./uploads/’.$img_path.‘_thumb.jpg';


Will do. Thanks, Helmet!

I encountered the same error while trying to use an absolute path to the thumbnail being created.

Sorry for the bump but this was the first result on Google on this matter.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.