 |
Your forum announcement here! |
|
 |

17-04-2008, 16:34
|
|
new member
|
|
Join Date: Jan 2008
Posts: 7
|
|
Resize Image
Hope this comes under the right section,
Anyway i'm looking into some sort of image resize, When members post pictures up on forum the image resizes to a non large image.
Anyone know of where i can get info on this, also its for phpbb3

|

17-04-2008, 21:09
|
 |
Premium Member
|
|
Join Date: Nov 2005
Location: New Mexico
Posts: 766
|
|
|

17-04-2008, 22:12
|
 |
Premium Member
|
|
Join Date: Jan 2007
Location: Amersham
Posts: 362
|
|
Quote:
Originally Posted by L33TRB
Hope this comes under the right section,
Anyway i'm looking into some sort of image resize, When members post pictures up on forum the image resizes to a non large image.
Anyone know of where i can get info on this, also its for phpbb3

|
Don't know how good your php is - but here is a routine i wrote for an ecommerce web site hosting i created. It takes an original picture and creates a medium and a thumbnail sized copy and saves them in appropriate places
PHP Code:
function resizeImage($img, $imgPath, $quality,$medPath,$thumbPath) {
// Open the original image.
list($width, $height, $type, $attr) = getimagesize($imgPath.$img);
//create new file name
$baseName = explode("_",$img);
$newNameE = explode(".", $img);
//medium image
$newName = $baseName[0] . '_med.'. $newNameE[1] ;
// Determine new width and height for medium image
if ($width>$height) {
$newWidth=120;
$newHeight=120*$height/$width;
} else {
$newHeight=120;
$newWidth=120*$width/$height;
}
// get the image
$original=createimage($imgPath.$img);
// Resample the image.
$tempImg = imagecreatetruecolor($newWidth, $newHeight);
if (!$tempImg) {
return false;
} else {
if (!imagecopyresampled($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height)) {
return false;
} else {
// Save the image.
if (!saveimage($tempImg,$medPath.$newName, $quality)) {
echo ' Problem with medium '.$newName;
return FALSE;
} else {
// Clean up.
echo ' Med <a href="'.$medPath.$newName.'" target="_blank">'.$newName.'</a>';
imagedestroy($tempImg);
}
}
}
// thumbnail
$newName = $baseName[0] . '.'. $newNameE[1] ;
// Determine new width and height for thumbnail image
if ($width>$height) {
$newWidth=72;
$newHeight=72*$height/$width;
} else {
$newHeight=72;
$newWidth=72*$width/$height;
}
// Resample the image.
$tempImg = imagecreatetruecolor($newWidth, $newHeight);
if (!$tempImg) {
return false;
} else {
if (!imagecopyresampled($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height)) {
return false;
} else {
// Save the image.
if (!saveimage($tempImg,$thumbPath.$newName, $quality)) {
echo ' Problem with thumb '.$newName;
return FALSE;
} else {
//Clean up
echo ' Thumb <a href="'.$thumbPath.$newName.'" target="_blank">'.$newName.'</a>';
imagedestroy($original);
imagedestroy($tempImg);
}
}
}
return true;
}
hope that helps 
|

17-04-2008, 22:21
|
|
new member
|
|
Join Date: Jan 2008
Posts: 7
|
|
Quote:
Originally Posted by DavidAllen
Don't know how good your php is - but here is a routine i wrote for an ecommerce web site hosting i created. It takes an original picture and creates a medium and a thumbnail sized copy and saves them in appropriate places
PHP Code:
function resizeImage($img, $imgPath, $quality,$medPath,$thumbPath) {
// Open the original image.
list($width, $height, $type, $attr) = getimagesize($imgPath.$img);
//create new file name
$baseName = explode("_",$img);
$newNameE = explode(".", $img);
//medium image
$newName = $baseName[0] . '_med.'. $newNameE[1] ;
// Determine new width and height for medium image
if ($width>$height) {
$newWidth=120;
$newHeight=120*$height/$width;
} else {
$newHeight=120;
$newWidth=120*$width/$height;
}
// get the image
$original=createimage($imgPath.$img);
// Resample the image.
$tempImg = imagecreatetruecolor($newWidth, $newHeight);
if (!$tempImg) {
return false;
} else {
if (!imagecopyresampled($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height)) {
return false;
} else {
// Save the image.
if (!saveimage($tempImg,$medPath.$newName, $quality)) {
echo ' Problem with medium '.$newName;
return FALSE;
} else {
// Clean up.
echo ' Med <a href="'.$medPath.$newName.'" target="_blank">'.$newName.'</a>';
imagedestroy($tempImg);
}
}
}
// thumbnail
$newName = $baseName[0] . '.'. $newNameE[1] ;
// Determine new width and height for thumbnail image
if ($width>$height) {
$newWidth=72;
$newHeight=72*$height/$width;
} else {
$newHeight=72;
$newWidth=72*$width/$height;
}
// Resample the image.
$tempImg = imagecreatetruecolor($newWidth, $newHeight);
if (!$tempImg) {
return false;
} else {
if (!imagecopyresampled($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height)) {
return false;
} else {
// Save the image.
if (!saveimage($tempImg,$thumbPath.$newName, $quality)) {
echo ' Problem with thumb '.$newName;
return FALSE;
} else {
//Clean up
echo ' Thumb <a href="'.$thumbPath.$newName.'" target="_blank">'.$newName.'</a>';
imagedestroy($original);
imagedestroy($tempImg);
}
}
}
return true;
}
hope that helps 
|
Thanks  My phpbb skills arent up to much, where exact do i put this 
|

17-04-2008, 22:30
|
 |
Premium Member
|
|
Join Date: Jan 2007
Location: Amersham
Posts: 362
|
|
I don't know phpbb - so can't help you as to exactly where to put it. It would need to go in the bit where the uploaded images are processed. If it's too much for you, it might be better to follow the link Brian gave as that appears to be some sort of pre-packaged mod for phpbb
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
All times are GMT. The time now is 05:26.
|
|
|