FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


I want to output an img url from a random image script





Enterprise
I've been googling this for literally two hours, and finding nothing that is exactly what I need. Forgive me , but I'm unfamiliar with PHP, so there's just no way I can do this myself. If you know of a tutorial that explains what I need, please point me in that direction, if you don't want to explain it to me yourself.

What I need is this: I want to generate an image url that I can display on any webpage that will display a random image from a directory. I've found numerous scripts on how to create the random image, and I've done that, but I don't know where to go from here, or if I'm even in the right direction at all.

Please help!
Marcuzzo
lets say you have 4 pictures...

picture0.gif
picture1.gif
picture2.gif
picture3.gif

Code:
<img src="picture<?php echo rand(0, 3) ?>.gif" alt="random Picture" />
Enterprise
I guess what I'm looking for is one url, like turn 4 .pngs into one .png file. Does that make sense? Sorry, I'm really bad at describing things since I'm totally new to PHP.
b4r4t
Then read PHP GD Library tutorials - it's Image manipulation lib for PHP Smile
There are a lot of tutorials on web ...
In short - it will be few steps:
1. Ceate blank, big png
2. Read 1st png and paste it in upper left
3. Read 2nd png an paste in in upper right
4. ... bottom left
5. ... bottom right
6. Save/output to browser the new created png file

Smile
rvec
To get all the images in a dir (easier than having to rename the images and editing the script everytime you add one):
http://us.php.net/manual/en/function.readdir.php

To make one image from multiple images you need GD like b4r4t said.

To get one image (a random one):
http://us.php.net/manual/en/function.array-rand.php <-- use that on an array you make with readdir()
http://us.php.net/manual/en/function.fpassthru.php <-- use that to output the image to the browser (don't forget to set the headers)
Related topics
Random image for your gallery
Random page generator
Site Nav Suggestions...
Jamatus' Dynamic image store
Where/How to display/host images
Random Image
image upload, and return url to image
Display random image on foreign site
Image Script not working.
Random images from directory
Random image script
host images?????
random image code?
IE8 not allowing new random image on each page (PHP and CSS)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.