FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a 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

select x random rows from database
Convert any video, DVD, Youtube clips to iPod, PSP, Zune
How to create iPod photo video with music&#65311;
The Archive of All Funny
Whats wrong with my code?

random content in page at every view?
some help scripting cgi
Used Jetta 2002
As you can See My sig is very cool as it is but...
firefox displaying odd behavior

Collect funny dog pictures - They don't have to be your own!
help with pcre syntax
In Command: Syntax Highlighting your code
My First HDR attempt
HÝSTORY OF TURKEY...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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