!RESOLVED! imagejpeg() :: checked everything still errors :(
Posted: Fri Mar 25, 2011 2:04 am
First post here...
First off, advanced thanks to anyone who spends time on this.
Here's the deal:
I'm trying to create a thumbnail of an uploaded user photo. I continue to get the following error:
Here are the relevant functions:
Any help would be greatly appreciated.
Thanks.
First off, advanced thanks to anyone who spends time on this.
Here's the deal:
I'm trying to create a thumbnail of an uploaded user photo. I continue to get the following error:
After scouring the nets, I've cleared up the possibility of it being a permissions issue (set to 777 for the sake of solving this problem), a safe_mode issue (set to 'off'), or an issue with the path (I think... I'm using $_SERVER['DOCUMENT_ROOT']).Warning: imagejpeg() [function.imagejpeg]: Unable to open '/home/v5w3defp/public_html/sprahl.com/private/avatars/' for writing: Is a directory in /home/v5w3defp/public_html/sprahl.com/private/includes/functions.php
Here are the relevant functions:
Code: Select all
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source = imagecreatefromjpeg($image);
imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
imagejpeg($newImage,$thumb_image_name,100);
}
function changePhoto($name){
$upload_path = $_SERVER['DOCUMENT_ROOT'] . "/private/avatars/";
$large_image_name = $name; // New name of the large image
$thumb_width = "100"; // Width of thumbnail image
$thumb_height = "100";
$thumb_image_location = $upload_path.$thumb_image_name;
$newname = $_SERVER['DOCUMENT_ROOT'] . '/private/user_photos/' . $large_image_name;
$width = getWidth($newname);
$height = getHeight($newname);
// Prepare to chop off excess
if($height > $width){
$y1 = ($height - $width)/2;
$x1 = 0;
$w = $width;
$h = $width;
}
if($width > $height){
$x1 = ($width - $height)/2;
$y1 = 0;
$w = $height;
$h = $height;
}
$scale = $thumb_width/$w;
$cropped = resizeThumbnailImage($thumb_image_location,$newname,$w,$h,$x1,$y1,$scale);
}
Thanks.