Welcome Guest, Not a member yet? Register   Sign In
Image Manipulation Problems
#1

[eluser]sshueso[/eluser]
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;

$this->image_lib->initialize($thumb);

$this->image_lib->resize();
if ($this->image_lib->resize())
{
echo 'image resized';
}
else
{
echo $this->image_lib->display_errors();
}
#2

[eluser]Helmet[/eluser]
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

/application
/photos
/system

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

Code:
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;
        
    $this->image_lib->initialize($config);
    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;

Result:

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

[eluser]Helmet[/eluser]
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

different/path/to/new/image/new_name/source_name.jpg

using the following:

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

[eluser]Helmet[/eluser]
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.
#5

[eluser]sshueso[/eluser]
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!
#6

[eluser]Helmet[/eluser]
Just add a file extension to your new_image value, like:

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

[eluser]sshueso[/eluser]
Aaaahhh.

Will do. Thanks, Helmet!
#8

[eluser]Unknown[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB