Square User Avatar

17 years 1 month ago #30561 by tomsawyer1234
Square User Avatar was created by tomsawyer1234
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:
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

Please Log in to join the conversation.

16 years 11 months ago #35407 by hermana_v
Replied by hermana_v on topic Re:Square User Avatar
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

Please Log in to join the conversation.

16 years 11 months ago #36485 by tomsawyer1234
Replied by tomsawyer1234 on topic Re:Square User Avatar
tks it work great!
it is far more design to have scquare portrait!!

cu
Florian

Please Log in to join the conversation.

16 years 10 months ago #36903 by ffaabbss
Replied by ffaabbss on topic Re:Square User Avatar
is that function using the following code mentioned here::
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...

Please Log in to join the conversation.

16 years 10 months ago #37118 by tomsawyer1234
Replied by tomsawyer1234 on topic Re:Square User Avatar
No, this function only rezite the picture into a square.

Please Log in to join the conversation.

16 years 10 months ago #37145 by ffaabbss
Replied by ffaabbss on topic Re:Square User Avatar
so is the polaroid function going ahead? any solution in sight?

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.192 seconds

Facebook Twitter LinkedIn