Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Simple Image Rotator, randomly rotate images
karlo
post Feb 25 2005, 03:48 AM
Post #1


Privileged Member
*********

Group: Members
Posts: 618
Joined: 30-October 04
From: Philippines
Member No.: 2,049



First, It's really confusing. Do you know any tutorials on Image Manipulation on PHP?

Here's another simple one:

1. Create a 5 image.
2. Rename them to something like: image1.jpg; image2.jpg; and so on...
3. Create your PHP file (rotation.php)
4. Enter the following code:

CODE
<?php

header("content-type: image/jpeg");
readfile("image".mt_rand(1,3).".jpg");

?>

5. Execute your script.
Go to the top of the page
 
+Quote Post
Dragonfly
post Feb 25 2005, 05:56 AM
Post #2


Privileged Member
*********

Group: Members
Posts: 702
Joined: 17-February 05
Member No.: 3,817



Could you please a little bit more elaborate. I'm interested in using this script. where do I keep the images and also file path is not mentioned clearly. Please...
Go to the top of the page
 
+Quote Post
rejected
post Feb 25 2005, 06:33 AM
Post #3


{([Mod])}
*********

Group: Members
Posts: 710
Joined: 30-October 04
From: Texas
Member No.: 2,058



You save the images in the directory as the rotation is in.
Go to the top of the page
 
+Quote Post
karlo
post Feb 25 2005, 08:00 AM
Post #4


Privileged Member
*********

Group: Members
Posts: 618
Joined: 30-October 04
From: Philippines
Member No.: 2,049



QUOTE(rejected @ Feb 25 2005, 02:33 PM)
You save the images in the directory as the rotation is in.
*



Yes. Or you can change it... example "images/rotate/ads/image"
Go to the top of the page
 
+Quote Post
egbakaet
post Feb 25 2005, 10:59 PM
Post #5


Newbie [Level 1]
*

Group: Members
Posts: 15
Joined: 25-February 05
From: Somewhere? LOL.
Member No.: 3,988



Here's an even easier way, if that's too complicated. lol.

CODE
<?
$show = 2; //change 5 to number of buttons you want to show
$button[] = "|-img code here-|";
$button[] = "|-img code here-|";
//and so on

srand ((float) microtime() * 10000000);
$Keys = array_rand($button, 3); //change 5 to number of buttons you want to show

for($K = 0; $K < $show; $K++){
echo "".$button[$Keys[$K]]."";
}
?>


Just add more lines of $button[] = "|-img code here-|"; to the code to make more images! Hope that helps! smile.gif
Go to the top of the page
 
+Quote Post
karlo
post Feb 26 2005, 10:14 AM
Post #6


Privileged Member
*********

Group: Members
Posts: 618
Joined: 30-October 04
From: Philippines
Member No.: 2,049



QUOTE(egbakaet @ Feb 26 2005, 06:59 AM)
Here's an even easier way, if that's too complicated. lol.

CODE
<?
$show = 2; //change 5 to number of buttons you want to show
$button[] = "|-img code here-|";
$button[] = "|-img code here-|";
//and so on

srand ((float) microtime() * 10000000);
$Keys = array_rand($button, 3); //change 5 to number of buttons you want to show

for($K = 0; $K < $show; $K++){
echo "".$button[$Keys[$K]]."";
}
?>


Just add more lines of $button[] = "|-img code here-|"; to the code to make more images! Hope that helps! smile.gif
*



It's more difficult! Especially in using Arrays! http://www.trap17.com/forums/index.php?showtopic=7711
Go to the top of the page
 
+Quote Post
chiclete
post Feb 26 2005, 04:57 PM
Post #7


Premium Member
********

Group: Members
Posts: 153
Joined: 21-December 04
Member No.: 2,829



I got this image rotator:

CODE
<?php

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = 'fotos/banner/';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
   foreach($exts as $ext) { // for each extension check the extension
       if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
           $files[] = $file; // it's good
           ++$i;
           }
       }
   }
closedir($handle); // We're not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along

header('Location: '.$folder.$files[$rand]); // Voila!
?>


It's working but I wanted it to make a .jpg file not a .php so I could put it on a forum... do you guys know if I can do it?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Calculator(17)
  2. Image Preloader With Progress Bar Status(23)
  3. Creating Links In Images(18)
  4. How To: Change Your Website's Index File(24)
  5. My Ipod Is Randomly Skipping Songs, Losing Data,(23)
  6. Program To Rotate Images 45 Degrees(9)
  7. Get Paid For People Viewing Your Images(44)
  8. Verifying Email Addresses(9)
  9. Simple C File Handling In Action(4)
  10. How To Create Embed Image Mail In Gmail(56)
  11. Wmp (windows Media Photo) - The New Image File Format From Microsoft(33)
  12. Playing Flash Movies Without The One-click Activation: Simple Insertion Of Javascript(4)
  13. Need To Shrink The File Size Of Web Image? - Photoshop Tricks(3)
  14. Adding Shine To Text(4)
  15. Very Simple Online Now Script(4)
  1. Do You Use Imagefilez.com?(36)
  2. Simple Php Login And Registration System(15)
  3. Simple Javascript And Password System(9)
  4. Help For My Seagate Sata Hard Drive!(9)
  5. Problem Aligning In Firefox(9)
  6. How To Create Cool Image Buttons(7)
  7. How To Make Image Buttons Act As Submit Button(8)
  8. Create Dynamic Html/php Pages Using Simple Vb.net Code(1)
  9. Flash Tutorial Simple Motion Tween(0)
  10. [request] Avatar For Trap17 Users(0)
  11. Finding The Rgb Color Of An Image(3)
  12. Testing Of The Auto Image Resizer(0)
  13. My Images Wontshow Online(2)


 



-