• 0

How do I do an avatar that "rotates"..


Question

I've seen people with avatars that rotate and change according to refreshes.

I've got a pretty cool idea for one, but I'd like to know how to do this first.

Thanks. :happy:

Link to comment
Share on other sites

19 answers to this question

Recommended Posts

  • 0

You could just have a php script on a server generate an image (through GD or imagemagick) from an existing image and rotate it every time it's called...

Link to comment
Share on other sites

  • 0

Not really a site/forum issue..

To go off of Gangsta, this is your best bet.

<?php
/*******************************************************************************
*       PHP AVATAR ROTATOR (or anything else for that matter)
*******************************************************************************/

$path = "/images/";     // Path to your avatar/sig folder relative to the root directory of your site

/******************************************************************************
*       DO NOT EDIT BELOW THIS LINE!
******************************************************************************/

$dir = $_SERVER['DOCUMENT_ROOT'].$path;
$avatars = array();

// Open avatar directory and read its contents into an array
if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                        if (filetype($dir.$file) == "file" && getimagesize($dir.$file)) {
                                array_push($avatars, $file);
                        }
                }
                closedir($dh);
        }
}

// Create random avatar
$img = $dir.$avatars[rand(0, count($avatars)-1)];
$info = getimagesize($img);

if ($info[2] == 2) {
        header('Content-Type: image/jpeg');

        $img = imagecreatefromjpeg($img);
        imagejpeg($img);
}

elseif ($info[2] == 3) {
        header('Content-Type: image/png');

        $img = imagecreatefrompng($img);
        imagepng($img);
}

else {
        header('Content-Type: image/gif');

        $img = imagecreatefromgif($img);
        imagegif($img);
}

imagedestroy($img);
?>

Copy the above code into a file called "avatar.php" and make sure that the directory reflects where you'll be uploading your images to for your avatars.

I believe Neowin/IPB disable allowing you to direct link URLs that have .php in it by default.. So you'll have to do some wizardry to make the avatar.php url an "image."

Create an .htaccess in the same location as avatars.php, and insert the following:

AddType application/x-httpd-php .png
RewriteEngine On
RewriteRule .png avatars.php

Now you'll link it like domain.com/avatar.png.

Link to comment
Share on other sites

  • 0

maybe they just manually change it a lot :p

moved here

Moved... to where I put it originally?

:wacko:

Link to comment
Share on other sites

  • 0

Not really a site/forum issue..

To go off of Gangsta, this is your best bet.

<?php
/*******************************************************************************
* PHP AVATAR ROTATOR (or anything else for that matter)
*******************************************************************************/

$path = "/images/"; // Path to your avatar/sig folder relative to the root directory of your site

/******************************************************************************
* DO NOT EDIT BELOW THIS LINE!
******************************************************************************/

$dir = $_SERVER['DOCUMENT_ROOT'].$path;
$avatars = array();

// Open avatar directory and read its contents into an array
if (is_dir($dir)) {
 if ($dh = opendir($dir)) {
 while (($file = readdir($dh)) !== false) {
 if (filetype($dir.$file) == "file" && getimagesize($dir.$file)) {
 array_push($avatars, $file);
 }
 }
 closedir($dh);
 }
}

// Create random avatar
$img = $dir.$avatars[rand(0, count($avatars)-1)];
$info = getimagesize($img);

if ($info[2] == 2) {
 header('Content-Type: image/jpeg');

 $img = imagecreatefromjpeg($img);
 imagejpeg($img);
}

elseif ($info[2] == 3) {
 header('Content-Type: image/png');

 $img = imagecreatefrompng($img);
 imagepng($img);
}

else {
 header('Content-Type: image/gif');

 $img = imagecreatefromgif($img);
 imagegif($img);
}

imagedestroy($img);
?>

Copy the above code into a file called "avatar.php" and make sure that the directory reflects where you'll be uploading your images to for your avatars.

I believe Neowin/IPB disable allowing you to direct link URLs that have .php in it by default.. So you'll have to do some wizardry to make the avatar.php url an "image."

Create an .htaccess in the same location as avatars.php, and insert the following:

AddType application/x-httpd-php .png
RewriteEngine On
RewriteRule .png avatars.php

Now you'll link it like domain.com/avatar.png.

Should have known there was going to be code for this... :(

I wonder if there's a way how to make it detect what theme Neowin is on.. thinking_emote.gif

I'm seriously going to need some help with this because as you know.. I can't understand code or anything to do with code, at all.

I'm done uploading the images I want to "cycle", I need to get to bed.. though.

I'll revive this in the morning.. :)

Link to comment
Share on other sites

  • 0

Moved... to where I put it originally?

:wacko:

you probably opened thread in the time between me posting that and me actually moving the thread, ipb adds the post before it actually moves the thread.

i was still deciding which forum to put it in when moving :p

Link to comment
Share on other sites

  • 0

you probably opened thread in the time between me posting that and me actually moving the thread, ipb adds the post before it actually moves the thread.

i was still deciding which forum to put it in when moving :p

Ooooh. Okay :)

Anyone interested in helping me get this working as I don't understand a lick of code? :laugh:

Link to comment
Share on other sites

  • 0

Hum I appreciate the effort.. but, I'm looking for a static image that just changes according to refresh:

Blue.pngMidnight.pngDarkside.pngBlack.png

Reddish.pngGrape.pngGreen.pngBrown.png

:happy:

Now you see why I'm thinking about seeing if there's a way how to detect what theme Neowin is on...

The 8 above are just experiments.

Link to comment
Share on other sites

  • 0

:blink:.

Why do two of them resize?

They're all the exact same size.. I made sure of it.

Oh and..

I'm not doing "Minifig" as the avatar..

I'm thinking about LEGO Fan.. or something.

Link to comment
Share on other sites

  • 0

I'll let you know when I have what I'm going to use Colin.. it'd be great if you could help me again :D

Link to comment
Share on other sites

  • 0

:blink:.

Why do two of them resize?

They're all the exact same size.. I made sure of it.

Oh and..

I'm not doing "Minifig" as the avatar..

I'm thinking about LEGO Fan.. or something.

I copied YOUR pics -- and 2 of them were a pixel off. :laugh:

Link to comment
Share on other sites

  • 0

Welp here's a test. Any thoughts?

DarksideHead.pngBlueHead.pngMidnightHead.pngBlackHead.png

ReddishHead.pngBrownHead.pngGrapeHead.pngGreenHead.png

It's basically an ultra simplified form of my avatar now, just with the Neowin Theme colors.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.