Arrow Home arrow Forums
larger font smaller font default font Fixed screen resolution Auto adjust screen size

Joomlapolis Forums  


<< Start < Prev 1 2 3 4 5 Next > End >>
Square User Avatar
Date: 2007/02/05 13:25 By: tomsawyer1234 Status: User  
Karma: 4  
Senior Joomlapolitan

Posts: 51
graphgraph
I have been searching all joomla's site forum and I could not find an answer to my simple need.

I would like to have square avatar/thumnails in CB. Square avatar looks a lot better on a desgn point of view!
Does anyone manage to achieve this?

I have found some mambot that can generate square image but i do not know how to integrate them into the "portrait" tab in cb profil.

Simple php script to obtain square thumnails:
http://www.findmotive.com/2006/08/29/create-square-image-thumbnails-with-php/
Can anyone help me to integrate it to cb!

thanks in advance for your help

Florian

Post edited by: tomsawyer1234, at: 2007/02/05 18:24
Click here to see the profile of this user The administrator has disabled public write access.

Re:Square User Avatar
Date: 2007/04/10 02:57 By: hermana_v Status: User  
Karma: 0  
Fresh Joomlapolitan

Posts: 3
graphgraph
Hi, Florian!

First of all, THANK YOU!!!
Thank you for this link of a script about square avatars.
This code, it was just so simple and genius
I've just managed to adapt it for CB. I'm not a programmer, i am far from it, but if you just get the priciples... then it's easy... So, my first experience in coding...

1. Find the file ".../administrator/components/com_comprofiler/imgToolbox.class.php"

2. Find the line "function resizeImageGD2", or, if you use another lib, like Imagemagick, find another (identical) function, respectively.

3. Replace the whole function (it ends with calling to another function, you'll notice) with this code:



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];

$thumb_size=100;

if($width> $height) {
$x = ceil(($width - $height) / 2 );
$width = $height;
} elseif($height> $width) {
$y = ceil(($height - $width) / 2);
$height = $width;
}

// 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($thumb_size, $thumb_size);
imagecopyresampled($dst_img, $src_img, 0, 0, $x, $y, $thumb_size, $thumb_size, $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;
}



That's it! It saves all the features of original code -

The function below will take an image and regardless of whether its a portrait or landscape size image it will generate a square thumbnail that is not distorted

Thank you! I hope it will help all the cbuilders who need this function.



Love,
Tanja
Click here to see the profile of this user The administrator has disabled public write access.

Re:Square User Avatar
Date: 2007/04/27 16:01 By: tomsawyer1234 Status: User  
Karma: 4  
Senior Joomlapolitan

Posts: 51
graphgraph
tks it work great!
it is far more design to have scquare portrait!!

cu
Florian
Click here to see the profile of this user The administrator has disabled public write access.

Re:Square User Avatar
Date: 2007/05/03 15:01 By: ffaabbss Status: User  
Karma: 5  
Gold Joomlapolitan

Posts: 290
graphgraph
is that function using the following code mentioned here::http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,24/id,35766/ target="_blank">
http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,24/id,35766/
or is that sommething else? I would love to have that polaroid function.. it is really genius...
Click here to see the profile of this user The administrator has disabled public write access.

Re:Square User Avatar
Date: 2007/05/07 10:30 By: tomsawyer1234 Status: User  
Karma: 4  
Senior Joomlapolitan

Posts: 51
graphgraph
No, this function only rezite the picture into a square.
Click here to see the profile of this user The administrator has disabled public write access.

Re:Square User Avatar
Date: 2007/05/07 18:34 By: ffaabbss Status: User  
Karma: 5  
Gold Joomlapolitan

Posts: 290
graphgraph
so is the polaroid function going ahead? any solution in sight?
Click here to see the profile of this user The administrator has disabled public write access.

<< Start < Prev 1 2 3 4 5 Next > End >>

Documentation

Documentation Subscription Service
(updated for CB 1.2 RC2)

What?

Why?

Where?

Just click here for answers!

Click here for a yearly subscription: subscribe now

Download Latest Release

The latest stable Community Builder Release is version 1.1 for Joomla 1.0 and Mambo.
You need to be a registered member of Joomlapolis to download.

The latest release candidate of Community Builder is version 1.2 RC3, native for Joomla 1.0, 1.5 and Mambo.
It is available as "thank you" to all CB documentation subscribers at this time.

CB Login