Topic: Avatar features

It would be really neat to have it so that you can upload an avatar of any size height or width, but have it sized down according to its large size so it doesnt look stretched. You could keep the image the same size but use html to do like <img height="" width="">. It would take some sort of math function to figure out what a good height and width to show so that it isnt stretched and is still small enough for the box there.

Then an addon to this mod that could be cool is to make it so when you click on the avatar it opens a full sized picture in a separate window (Very neat idea for a chatting forum)

An example of a site that does this is YouThink

I am using PunBB for a guitar/musicians website and this is a feature that would be very nice in the atmosphere of all these artists smile

Re: Avatar features

I dont know PHP but here is the basic mathematical idea

smaller dimension divided by larger dimension = variable
variable multiplied by 60 (largest dimension wanted in pixels) = outputted smaller dimension
outputted larger dimension equals 60

EX
an image 724 width by 528 height

528 / 724 = 0.729
0.729 * 60 = 44

Therefore the larger side (724) will be shown at 60 pixels
and the smaller side (528) will be shown at 44 pixels

Plug these numbers into an <img> html tag and you have a resized image that isnt stretched or distorted.

If someone could put this function into PHP for me I may be able to do the rest myself... MUCH appreciated

Re: Avatar features

wow, nevermind i figured out how to do it myself HEH im amazed.

Re: Avatar features

see my own little mod in action here

Re: Avatar features

That's not a really good solution either, now everybody must download the large file instead of a really small one. Your avatar is now 44kB, and it could be 5-10k instead.

There are php-tools to manipulate files, but then you have alot of more work to do :)

6 (edited by Falconey 2004-05-03 08:11)

Re: Avatar features

If you'd need such a function just use the php gd lib, netpbm or imagemagick libraries. You don't have to make your own code for that.

Then again, why would you want to resize a 1000x1000 picture to 60x60 and find out it looks like crap because of the proportions.

Re: Avatar features

good point however this is just going to have to do until i learn to code php. I have no idea how to use gd and such, however I do think those would be good features also, we'll see what happens i guess, but for now this will work fine for me.

8 (edited by sleddog 2004-05-03 21:42)

Re: Avatar features

I use ImageMagick a fair bit. Resizing is quite easy, for example,

$imginfo = exec("/usr/bin/identify $imagename");
$dimensions = explode(" ", $imginfo);
$dimensions = $dimensions[2];
$dimensions = explode("x", $dimensions);
$width = $dimensions[0];
$height = $dimensions[1];
if ($width > 60 || $height > 60) {
  exec("/usr/bin/mogrify -resize 60x60 -quality 80 +profile '*' $imagename");
}

-resize : sets the maximum height or width, preserving the aspect ratio;
-quality : sets the jpeg image quality/compression;
+profile '*' : strips out any header information stored in the image. For example, a photo from a digital camera will contain headers that add about 10kb to the image filesize and will be kept even in a tiny thumbnail if you don't strip them.

Needless to say, you have to adjust for your path to the ImageMagick binaries (/usr/bin in this example).

Maybe there's a simpler way of getting image dimensions with ImageMagick, dunno. I know it's easier with the GD library, but (IMO) ImageMagick produces much better quality results on resizing than GD.

Re: Avatar features

will this resize the image in proportion IE if its 40x20 will it make it 60x60(incorrect ratio) or 60x30(correct ratio)

Re: Avatar features

datapurge wrote:

will this resize the image in proportion IE if its 40x20 will it make it 60x60(incorrect ratio) or 60x30(correct ratio)

It will preserve the aspect ratio.

"Programming is like sex: one mistake and you have to support it for the rest of your life."