PHP Classes
elePHPant
Icontem

Magic Yahoo! Messenger Avatar Generator: Generate cool avatar images for Yahoo messenger

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2007-07-04 (8 years ago) RSS 2.0 feedNot enough user ratingsTotal: 496 All time: 5,422 This week: 1,450Up
Version License PHP version Categories  
magic_avatar 1.0GNU General Publi...4.3Graphics
Description Author  

This class can be used to generate avatar images for use with Yahoo messenger.

It takes an given image and generates two avatar images with standard sizes 16x16 and 96x96 respectively to be displayed in the friends list and while you are chatting.

The small image is the one your friends will see when they look at their contacts lists while big image is the one your friends will see when they point to your name in that list.

Optionally, the big image may have a given text that is rendered at the bottom of the avatar image.

The class may generate the avatar images in GIF, JPEG and PNG to files with given names.

Picture of Nima Nima
Name: Nima Nima <contact>
Classes: 4 packages by
Country: Iran Iran
Age: 23
All time rank: 134215 in Iran Iran
Week rank: 1587 Down43 in Iran Iran Down
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
 Magic Yahoo! Messenger Avatar Generator Class
 General Information - Documentation File


 
There is nothing hard to work with, to use the class do as the following:

1. Create a new class:
    [code]
        $avatar = new avatar();
    [/code]

2. Add both big and small images:
   a. From file names:
    [code]
        $avatar->addSmallImageFromFile("/path/to/image.png"); //$avatar->addBigImageFromFile("/path/to/image.png");
    [/code]

   b. From a GD Resource:
    [code]
        $avatar->addSmallImage($im); //$avatar->addBigImage($im);
    [/code]
    You may add one of the images by the A method and another one by the B method! It's obvious, ha?
    Note that the small image will be resized to 16x16 and the big image will be resized to 96x96 pixels.

3. {OPTIONAL STEP} Put a little text under the final avatar:
    [code]
        $avatar->addText(string $text [, integer $size [, array $coltext [, array $colrect]]]);
    [/code]
    Enter color arrays as the following: array(r, g, b)
    Default values are:
    $size: 2        $coltext: array(255, 255, 255)      $colrect: array(0, 0, 0)

    ** ALWAYS use addText() before doing the next step **

4. Mix 'em! (this is the abracadabra part :-D)
    [code]
        $avatar->mix();
    [/code]

    mix() will return false if an error occured during the steps!

5. And the final job:
   a. Save avatar's file:
    [code]
        $avatar->saveAvatar("/path/to/the/avatar.png");
    [/code]

   b. Show the avatar:
    [code]
        $avatar->showAvatar("avatar.png");
    [/code]
    showAvatar() will return false if headers have been already sent.
    Not only $filename is used for when user wants to Right Click -> Save Image As..., but it also determines
    the image's type and the mime-type which should be passed to the user!
    If nothing entered as the value of $filename, class will generate a JPEG image.

   c. Let's see, you may have imageABC() function for example (assume ABC is an image format) and you want to show it to the user!
   There is no problem, you can call getAvatar() and have cache headers with sendCacheHeaders() and make your ABC image as the following:
    [code]
        $im = $avatar->getAvatar();
        $avatar->sendCacheHeaders();
        header("Content-type: Image/ABC");
        imageABC($im);
        $avatar->destroy();
        imagedestroy($im);
    [/code]
    ********** Remember not to change $im anymore! this would probably make avatar not to show properly! **********

6. Free the allocated memory!
    [code]
        $avatar->destroy();
    [/code]




    And we're done!
  Files folder image Files  
File Role Description
Plain text file avatar.class.php Class Main Class
Plain text file COPYING Lic. GNU GPL
Plain text file example.php Example Example
Accessible without login Plain text file README Doc. General Information - Documentation File
Image file small.png Data 16x16 Image
Image file big.png Data 96x96 Image

 Version Control Unique User Downloads Download Rankings  
 0%Total:496All time:5,422
 This week:0This week:1,450Up
 User Comments (1)  
 
Cool start.
5 years ago (F Philip DeGeorge)
72%StarStarStarStar