Version: 1.00, by The Geek
Developer Last Online: Jan 2019
Version: 3.0.7
Rating:
Released: 03-16-2005
Last Update: Never
Installs: 33
Is in Beta Stage
No support by the author.
Basically this is a very simple addition to stop the mega computer literate who use my forums driving everyone insane with their 'I tried to upload my pic as an avatar but its too big - how do I resize it'.
In a nutshell, this will automatically resize the uploaded avatar (and profile picture) to your max dimensions (if it is too big).
It must still be smaller than the Custom Avatar Maximum File Size (bytes) / Profile Picture Maximum File Size (bytes) setting. In fact - it wont even get uploaded if the pic exceeds this size. Therefore I would suggest raising this limit to an appropriate amount.
There is 1 file edit (1 line) and 1 include file.
(Im going to get pissed if someone says there is already a hack for this )
change log
----------- Update to BETA 1.02 on 18/03/05
Added GD test
Fixed dumb typo that caused image dimensions to not be retrieved.
nJoy
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I just tried uploading a pic of an animated GIF, that is 120 pixels. I set the max width to 90 in my CP.
This is the error Im getting with an animated gif:
PHP Code:
Warning: imagecreatetruecolor(): Invalid image dimensions in /includes/functions_geekautoavatar.php on line 44
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /includes/functions_geekautoavatar.php on line 45
Warning: imagegif(): supplied argument is not a valid Image resource in /includes/functions_geekautoavatar.php on line 53
Warning: imagedestroy(): supplied argument is not a valid Image resource in /includes/functions_geekautoavatar.php on line 58
AHA! I figured it out!
I had the same problem with a jpeg that was perfectly square. The problem lies in the function starting at line 30.
Code:
//decide which is the % of shrinkage to use
if ($shrinkx<$shrinky){
$ratio=$shrinkx;
}elseif($shrinky<$shrinkx){
$ratio=$shrinky;
}
What's happening is that since it's square, the ratios are the same and there's no condition to handle it so it sets $ratio to 0
The fix is simple
Code:
//decide which is the % of shrinkage to use
if ($shrinkx<$shrinky){
$ratio=$shrinkx;
}elseif($shrinky<$shrinkx){
$ratio=$shrinky;
}else{
$ratio=$shrinkx;
}
We just upgraded to 3.5.1 this past week, and I had installed this hack previously. Just tested both the Avatar and Profile picture upload to make sure it is resizing the images to the limits set, and it seems to be working fine still. After the upgrade I also changed some of the code in the templates for each, to let members know that it will auto resize their images for them, and what the file size limits are. (See screenshots)