Random Image Generator Image Size?

So I found this tutorial on how to generate images from a folder which works great. I needed this code as most php tutorial ask you to rename your images to 1, 2, 3 etc. I wanted a image generator which allows the images to be any name.

I now need to resize the images to fit?

Here is the code I have got:

<?php $imgpath = "images/"; $handle = opendir( "$imgpath" ); $imgArray = array(); while($file = readdir($handle)) { if( $file != "." && $file != ".." ) { array_push( $imgArray, $file ); } } closedir( $handle ); mt_srand( (double)microtime( ) * 1000000 ); $randval = mt_rand( 0, sizeof( $imgArray ) - 1 ); print( ""); ?>

I am not sure how to add a width and height section in there, any ideas?

UPDATE!

I just added a width code at the bottom -

print( “<IMG SRC=”$imgpath/" . $imgArray[ $randval ] . “” width=50% >");

and worked fine!!

So, how do I align the image?

Sponsor our Newsletter | Privacy Policy | Terms of Service