Advertisement:

Author Topic: Fun with GD  (Read 5221 times)

Offline dschwab9

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,320
  • Gender: Male
    • Technology, Ministry and Other Ramblings
Fun with GD
« on: December 07, 2003, 03:08:36 AM »
I decided to dress up my forum a bit for the holidays.  Put in the santa smilies, added icicles to the new post indicator.

Then, got to playing with vector-based snow flakes, and things grew from there and I really got carried away   ;D  Already had a script that rotated through 9 random logos, and I thought it would be cool to put snow flakes over it.

So, I made me up 3 different flakes, aranged them into 5 transparent PNG-24 files the same size as my logo with snowflakes in different positions, modified my script to pic a random logo and random snowflake and merge them together, and now I have 45 different combinations of logos and snow flakes  :D

* dschwab9 like GD!

Click refresh a few times:
The normal one:

And the holiday one:


I'm sure it's hard on the CPU, but I like it!
« Last Edit: December 07, 2003, 03:11:55 AM by dschwab9 »

Offline writeto

  • Jr. Member
  • **
  • Posts: 341
  • Gender: Male
  • Professional Appreciator
Re: Fun with GD
« Reply #1 on: December 07, 2003, 05:18:51 AM »
I think it is wonderful that you are being seasonal, I just hope you have a way to turn off the flying snowflakes because after about 2 weeks of every site doing it I want to stop surfing the net. BTW I really like the snowflake effect on your logo that is very nice.

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Fun with GD
« Reply #2 on: December 07, 2003, 12:58:10 PM »
that's cool! I have to learn GD to do some scripts I need too  :-\

btw, don't you have or can get pics of jeeps in a snow covered scenery? that'd be pretty fitting too ;)
Cristián Lávaque http://cristianlavaque.com

Offline dschwab9

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,320
  • Gender: Male
    • Technology, Ministry and Other Ramblings
Re: Fun with GD
« Reply #3 on: December 07, 2003, 01:37:45 PM »
I think it is wonderful that you are being seasonal, I just hope you have a way to turn off the flying snowflakes because after about 2 weeks of every site doing it I want to stop surfing the net. BTW I really like the snowflake effect on your logo that is very nice.

These don't fly, they are just static images.  I don't like the flying ones either.  I tried to dress it up a bit without being annoying.  Look at http://bbs.zuwharrie.com

Quote
I have to learn GD to do some scripts I need too

It's actually pretty easy - this is what I'm using:
My code ould probably be cleaned up and be even simpler - I think I've got some redundant stuff in the random selection part.  I looked at the load on the server while loading it, and I don't notice any difference.  I think the images are small enough it really doesn't have an impact on the load time.

Code: [Select]
<?php
//
// ****LOAD THE MAIN IMAGE****
//
// Look for images in this folder
$folder "/home/sites/site17/web/bbs/images/header/";

// Load all the JPG filenames into an array
$fileList = array();
$handle opendir($folder); 
while (false !== ($file readdir($handle) ) ) {
if (substr($file, -4) == ".jpg") {
$fileList[count($fileList)] = $file;
}
}
closedir($handle);

// Choose a random image
$randNum rand0, (sizeOf($fileList) -1) );

// Load it into GD
$photoImage ImageCreateFromJPEG($fileList[$randNum]);
ImageAlphaBlending($photoImagetrue);

//
// ****LOAD THE OVERLAY****
//
// Load all the PNG filenames into an array
$fileList2 = array();
$handle2 opendir($folder); 
while (false !== ($file2 readdir($handle2) ) ) {
if (substr($file2, -4) == ".png") {
$fileList2[count($fileList2)] = $file2;
}
}
closedir($handle2);

// Choose a random overlay image
$randNum2 rand0, (sizeOf($fileList2) -1) );

// Load it into GD
$logoImage ImageCreateFromPNG($fileList2[$randNum2]);
$logoW ImageSX($logoImage); 
$logoH ImageSY($logoImage); 

// Overlay the PNG onto the JPG
ImageCopy($photoImage$logoImage1100$logoW$logoH); 

// Generate the headers
Header "Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header "Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
Header "Cache-Control: no-store, no-cache, must-revalidate");
Header "Cache-Control: post-check=0, pre-check=0"false);
Header "Pragma: no-cache");
Header "Content-type: image/jpeg");
Header "Content-Disposition: inline; filename=$image");

// Output it to the browser as a JPEG
ImageJPEG($photoImage,&#39;&#39;,70);
ImageDestroy($photoImage); 
ImageDestroy($logoImage); 
?>


Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Fun with GD
« Reply #4 on: December 07, 2003, 02:24:39 PM »
your board looks very nice ;)

I should start working on mine's look sometime soon  :-\

btw, I will certainly have to learn GD soon to write a mod I've been planning to write since a long time ago... a call it "gallery threads"... I even did a little photoshop to show my idea to a friend once, I guess I'll put it here and ask you what you think about the idea :)

http://anguz.net/yabbse/mods/gallerythread.jpg

there'll be lots of options that you can probably not tell from that image, but you can guess some... the thread would be started like the poll ones, with a gallery button... each page in the thread will be for each picture and all it's comments, the first page being for all the thumbs together like an index, to jump to the one you want

anyway, I hope I can work on it soon... first I have to finish 3 webpages, 2 for clients and one for myself :P

thank you for showing us your work with the pictures, I liked it a lot  :D
Cristián Lávaque http://cristianlavaque.com