|
|
Re:Square User Avatar
|
|
Date: 2007/05/09 18:46
|
By: tomsawyer1234
|
Status: User
|
|
|
Karma: 4  
|
|
Senior Joomlapolitan  | Posts: 51 |   | |
|
hermana_v,
I have setup the code you propose for my CB/Joomla installation but I have notice that the image get resized to "$thumb_size=100; " for both main profil image and small thumbnails (used for the connexions" tab for example).
Do you have the same behaviour?
concerning the polaroid iamge, I have look at it but I didn't manage to integrate it, but it should be easy for someone with god php knowledge.
regards
Florian
|
|
The administrator has disabled public write access. |
|
|
|
Re:Square User Avatar
|
|
Date: 2007/05/10 19:05
|
By: hermana_v
|
Status: User
|
|
|
Karma: 0  
|
|
Fresh Joomlapolitan  | Posts: 3 |   | |
|
Yes, Florian, i had the same issue. Now it's fixed and with this code you'll have thumbnails with dimensions you specify in CB backend(maximum, they say) and profile images with maximum dimensions you also specify in that backend.
function resizeImageGD2($src_file, $dest_file, $destWidth,$destHeight){ $imginfo = getimagesize($src_file); if ($imginfo == null) { $this->raiseError("Error: Unable to execute getimagesize function"); return false; } $width=$imginfo[0]; $height=$imginfo[1]; if($width> $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height> $width) { $y = ceil(($height - $width) / 2); $height = $width; }
$destWidth = $destHeight; $destHeight = $destWidth; // GD can only handle JPG & PNG images if ($imginfo[2] != 2 && $imginfo[2] != 3 && ($imginfo[2] == 1 && !function_exists(imagecreatefromgif))){ $this->raiseError("Error: GD2 Unable to create image from imagetype function"); return false; } if ($imginfo[2] == 2) $src_img = imagecreatefromjpeg($src_file); elseif ($imginfo[2] == 1) $src_img = imagecreatefromgif($src_file); else $src_img = imagecreatefrompng($src_file); if (!$src_img) { $this->raiseError("Error: GD2 Unable to create image from imagetype function"); return false; } $dst_img = imagecreatetruecolor($destWidth, $destHeight); imagecopyresampled($dst_img, $src_img, 0, 0, $x, $y, $destWidth, $destHeight, $width, $height); if ($imginfo[2] == 2) { imagejpeg($dst_img, $dest_file, $this->_JPEGquality); } elseif ($imginfo[2] == 1) { if(function_exists('imagegif')) { imagegif($dst_img, $dest_file); } else { $this->raiseError("Error: GIF Uploads are not supported by this version of GD"); return false; } } else { imagepng($dst_img, $dest_file); } imagedestroy($src_img); imagedestroy($dst_img); return true; }
But there's a small issue: profile image dimensions are in some sort unpredictable. For example, i have 2 different images with the same original dimensions, but in the end i receive profile images with different size, one cropped to 250x250 as i specified in backend, and one to 188x188 which i didn't expect.
maybe it relates to cropping behavior which is in some way centered.
Very glad you appreciate my work!
Cheers, Tanja
|
|
The administrator has disabled public write access. |
|
|
|
Re:Square User Avatar
|
|
Date: 2007/05/10 20:00
|
By: tomsawyer1234
|
Status: User
|
|
|
Karma: 4  
|
|
Senior Joomlapolitan  | Posts: 51 |   | |
|
Tks!
I have also notice the small bug but it is acceptable. The function could be optimized. I someone good at PHP could have a look at it!
I think this function should be a standard in CB!
|
|
The administrator has disabled public write access. |
|
|
|
|
Re:Square User Avatar
|
|
Date: 2007/06/15 05:13
|
By: wired
|
Status: User
|
|
|
Karma: 0  
|
|
Fresh Joomlapolitan  | Posts: 3 |   | |
|
Awesome guys!! But can this be adapted to first resize then crop from the center like http://fredfred.net/skriker/index.php/iimage-gallery ?
crop="true" crop_center="true" max_side="100" quality="95"
That way it's just not a simple crop. Looks way better.
|
|
The administrator has disabled public write access. |
|
|
|
|
Re:Square User Avatar
|
|
Date: 2007/06/15 05:54
|
By: wired
|
Status: User
|
|
|
Karma: 0  
|
|
Fresh Joomlapolitan  | Posts: 3 |   | |
|
|
Wow, got it to work by just throwing that in there!
|
|
The administrator has disabled public write access. |
|
|
|
Re:Square User Avatar
|
|
Date: 2007/06/15 22:11
|
By: Dionysus
|
Status: User
|
|
|
Karma: 3  
|
|
Senior Joomlapolitan  | Posts: 67 |   | |
|
|
Can you tell me where to add in this code?
|
|
The administrator has disabled public write access. |
|
|