PHP Classes

File: README

Recommend this page to a friend!
  Classes of Nima Nima  >  Magic Yahoo! Messenger Avatar Generator  >  README  >  Download  
File: README
Role: Documentation
Content type: text/plain
Description: General Information - Documentation File
Class: Magic Yahoo! Messenger Avatar Generator
Generate cool avatar images for Yahoo messenger
Author: By
Last change: .
Date: 14 years ago
Size: 2,675 bytes
 

Contents

Class file image Download
 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!
For more information send a message to info at phpclasses dot org.