30 Sep
When you load up a profile pic using the geekgrl profile picture plugin which is also basically the same plugin used by suleiman for wpmu the gd graphics library php code in these plugins squash or stretches the thumbnails.
You can see what I mean below.
Here’s an orginal picture:

Here’s the photo thumbnail with the original plugin code - squashed:

Here’s the photo resized and cropped from the center with my code:

Here’s the code that you need to replace:
For a 64 thumbnail cropped from center replace the following:
$new_image = imagecreatetruecolor(64,64);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, 64, 0, $dimensions[0], $dimensions[1]);
imagejpeg($new_image, “$medium_file_path”);
imagedestroy($new_image);
With this new code:
list($ow, $oh) = getimagesize($_FILES[’picture’][’tmp_name’]);
$big = imagecreatefromjpeg($_FILES[’picture’][’tmp_name’]);
$new_image = imagecreatetruecolor(64,64);if ($ow > $oh) {
$off_w = ($ow-$oh)/2;
$off_h = 0;
$ow = $oh;
} elseif ($oh > $ow) {
$off_w = 0;
$off_h = ($oh-$ow)/2;$oh = $ow;
} else {
$off_w = 0;
$off_h = 0;
}
imagecopyresampled($new_image, $big, 0, 0, $off_w, $off_h, 64, 64, $ow, $oh);
imagejpeg($new_image, “$medium_file_path”);
imagedestroy($new_image);
One Response
Would like love view the article with the images available. They are not showing up for me.
Thanks.
Leave a reply