View Full Version : Geek Auto Avatar Resizer
The Geek
03-16-2005, 10:00 PM
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
T3MEDIA
03-17-2005, 09:43 PM
Wooohahaha.... There is a hack for this.
Mini did it. It not only does avaies... but the profile picture as well.
been using it for about 4-5 months now.
Now I dont think its on the fly or anything like that. its a lengthy install (compared to what you said your install is)
and I dont know how good yours is. But his does work
The Geek
03-17-2005, 09:50 PM
ah poo. O well. hmmm. This may do profile pics too... ill have to look into it (the function its in looks like it handles all image uploads).
The Geek
03-17-2005, 10:03 PM
Whelp - for love nor money can I find the modification your talking about. Regardless - here is this one for your dining pleasure.
BTW: It does Profile Pictures too.
GamerzWorld
03-17-2005, 10:06 PM
Problem : it seems to resize images which are smaller ie enlarge and distort
Blam Forumz
03-17-2005, 10:49 PM
Sorry Geek, someone beat you to it :(
https://vborg.vbsupport.ru/showthread.php?t=68429
The Geek
03-17-2005, 10:57 PM
Thanks for the link.
Looks like it is about the same kind of thing - but handled a bit differently. No phrase installs or anything like that. Its a one line modification.
I guess ill keep it as its done now.
PS - small images resizing is fixed now.
yoyoyoyo
03-18-2005, 12:40 AM
thanks for sharing!
AN-net
03-18-2005, 01:17 AM
if a GD library is required i would state it;)
The Geek
03-18-2005, 08:59 AM
Updated package to test for GD support (it checks you vB options). If none is present then it skips the proceedure (the proceedure uses the GD library which is pretty standard stuff).
Does this resize GIFs, and also keep animations?
T3MEDIA
03-19-2005, 03:26 PM
Does this resize GIFs, and also keep animations?
The hack I am talking about removes the animations.... so that would be cool
Interesting idea..... but what if their avatar is SMALLER than the max deminsions?
bigcurt
03-20-2005, 08:15 PM
lol, he already solved that problem :P it does not resize it.
Blam Forumz
03-20-2005, 08:25 PM
can you make it use imagemagick instead of GD so it supports gifs and keeps the animations?
The Geek
03-21-2005, 09:47 PM
Im sure I could if I kew the methods it uses. Since I dont have it I dont think I could whip anything up too easily.
Havent tested with ani gifs yet though my instinct would say no
so this script, as is, would probably make an animated gif static?
If so, that would be cool if you wanted to not allow animated gifs as avatars and keep them a certain size (which I do :) )
The Geek
03-23-2005, 06:34 AM
not too sure - I havent tested it. I can only assume that it will :)
Blackhat
03-24-2005, 09:17 AM
what about large avatars that is allready uploaded ?
The Geek
03-24-2005, 10:18 AM
what about large avatars that is allready uploaded ?
it only does the resizing during first upload.
I just installed this but I'm still getting the error "That image is too large. The maximum dimensions are 48 by 48 pixels."
I am trying to upload a 100x60 (1.16KB) or a 100x100 (4.62KB) gif image and my forum settings are at "48 by 48 pixels or 9.8 KB (whichever is smaller)".
If I'm understanding this hack correctly, it should be resizing the 100x60 or the 100x100 image to 48x48 and not givng the error message?
Any ideas?
The Geek
03-25-2005, 06:34 AM
I just installed this but I'm still getting the error "That image is too large. The maximum dimensions are 48 by 48 pixels."
I am trying to upload a 100x60 (1.16KB) or a 100x100 (4.62KB) gif image and my forum settings are at "48 by 48 pixels or 9.8 KB (whichever is smaller)".
If I'm understanding this hack correctly, it should be resizing the 100x60 or the 100x100 image to 48x48 and not givng the error message?
Any ideas?
Check that your GD settings are correct. If its set to none - it will bypass the routine.
MajidOnline
03-25-2005, 01:05 PM
Dear The Geek,
Thank you,
This is a useful hack.
Check that your GD settings are correct. If its set to none - it will bypass the routine.
My GD settings are at 2+
Any other suggestions?
I just double checked my GD version and it is 2.0.28
The Geek
03-26-2005, 08:09 AM
What I mean is what the GD setting is put to in vboptions (which I think you said was 2+?).
Are you having the same problem with GAS3.51? It uses almost the same exact proceedure to resize uploads - however it doesnt test for GD support.
Let me know :)
lazee
03-26-2005, 03:15 PM
Really neat .working perfectly on 3.0.7
Thank you The Geek
Click Install
What I mean is what the GD setting is put to in vboptions (which I think you said was 2+?).
Yep, in vboptions my GD setting is 2+
Are you having the same problem with GAS3.51? It uses almost the same exact proceedure to resize uploads - however it doesnt test for GD support.
I haven't tried uploading a picture with GAS3.51, but I will do that now...
Weird. I just did a test article with a big graphic and GAS3.51 resized it perfectly.
I just re-applied the GARR hack and it still didn't work. It's almost like it's not even calling the functions_geekautoavatar.php file (or it's not passing the GD test for some reason).
Any ideas?
Could it be a problem with the GD test in the php file? Is there a version without the test that I could try?
The Geek
03-31-2005, 02:39 PM
Could it be a problem with the GD test in the php file? Is there a version without the test that I could try?
rrr, commenting out the gd test. Open the functions_geekautoavatarresizer.php and change:
if ($vboptions['gdversion']){
to
//if ($vboptions['gdversion']){
you will also need to comment out the last } on the page
replace:
}
?>
with
//}
?>
Let me know if that helps!
Thanks for the reply, Geek.
Man, I don't know what's going on here. I commented out those lines and no luck.
I tried a png file a jpg file and a gif file, and none of them resized, I still got the dimensions to large error like it wasn't doing the shrinking at all.
I tried changing require_once('./includes/functions_geekautoavatar.php');
to the full path to that file and still nothing.
I'd almost feel better if there was SOME sort of php error that gave me a hint what to look for. But noooo, it's just being passive agressive an saying:
"That image is too large. The maximum dimensions are 48 by 48 pixels."
The Geek
03-31-2005, 06:17 PM
Thanks for the reply, Geek.
Man, I don't know what's going on here. I commented out those lines and no luck.
I tried a png file a jpg file and a gif file, and none of them resized, I still got the dimensions to large error like it wasn't doing the shrinking at all.
I tried changing require_once('./includes/functions_geekautoavatar.php');
to the full path to that file and still nothing.
I'd almost feel better if there was SOME sort of php error that gave me a hint what to look for. But noooo, it's just being passive agressive an saying:
"That image is too large. The maximum dimensions are 48 by 48 pixels."
stick some echo commands in to see if the script is getting called and where its failing.
If you look at the code - its almost identical to the one in functions_geekarticles_images.php
In fact, all I did was port it over so I could have an easy way for users to upload avatars and profile pictures without the constant posting about 'how do I resize my picture?'.
Just every few lines in it - put
echo("Im here now- 1");
echo("Now Im here 2");
etc...
And see where you get. Other than that - I dont know what to tell you ;)
trulylowcarb
04-01-2005, 01:20 PM
I am having the same problems, does not resize large images and gives me the standard error, image too big. Uploading to GAS3.51 works perfectly however, and am using GD2+ image editor settings....
If you have a chance to look into the other gallery popup issue I PM'd you admin logins for, perhaps you could take a peek at this as well then... This is a much-needed upgrade for the obvious reasons you stated when you released it. Keep up the great work, Geek.
PS: Tried commenting out the GD test parts already, didn't help.
The Geek
04-01-2005, 01:52 PM
I am having the same problems, does not resize large images and gives me the standard error, image too big. Uploading to GAS3.51 works perfectly however, and am using GD2+ image editor settings....
If you have a chance to look into the other gallery popup issue I PM'd you admin logins for, perhaps you could take a peek at this as well then... This is a much-needed upgrade for the obvious reasons you stated when you released it. Keep up the great work, Geek.
PS: Tried commenting out the GD test parts already, didn't help.
excellent. Ill look into this and find out whats up!
The Geek
04-01-2005, 05:14 PM
Cool. Found out what I think the problem is with some users not getting this to work.
I would lay money on the fact that those having problems store their avatars in the DB instead of the filesystem.
So, if thats the case... try this:
edit includes/functions_upload.php and after EACH (there are 2):
$maxsize = &$imagepermissions[$type . 'maxsize'];
add
require_once('./includes/functions_geekautoavatar.php');
The problem is that the first one never gets called if you use the DB to store images. The second will catch it though!
Thanks for posting the fix, Geek. That worked perfectly!
The autoresizer is working great on my site now.
small note:
One thing I noticed during my testing was that if the image was a grayscale GIF image, I got the following error:
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
I would lay money on the fact that those having problems store their avatars in the DB instead of the filesystem.
Just curious...is it bad to store the avatars in the DB instead of the filesystem?
I don't think it was a conscious choice I made when setting up my site. Which is better for site performance/speed?
The Geek
04-04-2005, 08:33 PM
DB storage for images is not really a good thing.
Its the default as it gets around problems with php safemode - however it is slower and bogs your DB down more so than a file system. Saying that - its most likely only noticable in larger boards.
Ill look into the greyscale system woe. FIrst I have heard of it :)
FleaBag
04-12-2005, 11:37 PM
Excellent work, thanks loads. :)
FightRice.com
04-24-2005, 08:46 PM
I tried to install this, and i think it got it all installed :D
But then i go and test out an avatar to upload and it still tells me it is too big :(
Any ideas? No errors or anything like that
The Geek
04-25-2005, 06:24 AM
I tried to install this, and i think it got it all installed :D
But then i go and test out an avatar to upload and it still tells me it is too big :(
Any ideas? No errors or anything like that
Dimension wise or byte wise?
If you are storing them in the db, check a few posts back that lists a fix for db avatar storage
Allan
05-07-2005, 10:22 AM
Work Perfectly with 3.0.7, thank Geek :)
~~~~~~~~~~~~~~~~~~~
Click install
~~~~~~~~~~~~~~~~~~~
|Jordan|
05-07-2005, 04:15 PM
So are animations lost when scaling?
mkdevo
05-24-2005, 09:56 AM
hi
this was working fine for me for a while, but suddenly, i'm getting the following error when i try to upload an image for an avatar:
Fatal error: Call to undefined function: imagecreatefromjpeg() in /home/www/pbfans/forum/includes/functions_geekautoavatar.php on line 10
also happens with gif and png... any ideas?
The Geek
05-24-2005, 10:09 AM
hi
this was working fine for me for a while, but suddenly, i'm getting the following error when i try to upload an image for an avatar:
also happens with gif and png... any ideas?
That is an internal php function that is being called based on your GD settings. Check and make sure its right (vb options->Server Settings (i think))
Jordan - not too sure - havent tested it for that. However I can only assume it would.
wildondallas
05-30-2005, 10:31 PM
Installed and working great! Hoping this will increase people adding photos for their profile picture and avatar. Thanks for this hack :up:
Stachel
05-31-2005, 04:45 PM
If I have a pic that is 150x100
and avatar limits are 100x100
Will it look distorted when the avatar is uploaded (because it gets changed to be a perfect square) ?
Stachel
The Geek
05-31-2005, 07:53 PM
If I have a pic that is 150x100
and avatar limits are 100x100
Will it look distorted when the avatar is uploaded (because it gets changed to be a perfect square) ?
Stachel
It keeps the ratio - so your image will end up something like 100x75 when done
paul41598
06-18-2005, 08:30 PM
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:
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
The Geek
06-19-2005, 09:05 AM
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:
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
Does it not happen with a standard gif? To be honest it looks like the GD settings in vboptions is incorrect.
paul41598
06-19-2005, 11:42 AM
No it works fine with a standard gif actually. Animated though errors out.
DimensionZero
08-17-2005, 04:01 AM
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:
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.
//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
//decide which is the % of shrinkage to use
if ($shrinkx<$shrinky){
$ratio=$shrinkx;
}elseif($shrinky<$shrinkx){
$ratio=$shrinky;
}else{
$ratio=$shrinkx;
}
Just set ratio to one of the 2 shrink values.
Hope this helps you all out! :D
wildondallas
11-26-2005, 05:46 AM
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)
ConqSoft
11-26-2005, 05:52 AM
Umm, 3.5.x has built in Avatar and Profile Pic resizing. ;)
wildondallas
11-26-2005, 05:56 AM
Umm, 3.5.x has built in Avatar and Profile Pic resizing. ;)
Ha ha ha, shows you what I know...I saw some people requesting something for it in the 3.5 mod request forum here: https://vborg.vbsupport.ru/showthread.php?t=100768
Maybe they don't know either.LOL Thanks:)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.