How to set the size of an image


I have the following code on my Web page:

<?php $availabilityFile = ""; // ""; readfile( $availabilityFile ); ?>


I want to be able to set the size of the image so it doesn’t fill the entire page. What code would I add to this to do that? Thank you.


Well, that’s not an image, its a folder. you could use the gd library, or just hardcode it using an img width and/or height attribute.


anothr option is to use a dynamic resizing script such as timThumb

to resize an image you place the php file on your server then point to the file pass it the image path and desired dimension inside an img tag like:

<img src="timthumb.php?src=image.jpg&w=180">

Look at the demos


Another alternative would be to use a table. Simple… Just create a table with width=“100%” and it will fill the page across fully. And, put everything inside the table. Just create a table with one row and one TD and put all your page code inside that. I have done it and it works well.


Though that would work using tables for layout is bad practice it’s best to use Symantec markup instead such as divs withs CSS applied for styling tables are best used for tabular data


Yes, if it is truly an image, you could just use PHP’s image functions to resize it to the width of the current screen or to a set size like 800x600. Or, just use a “width=100%” for the tag. Tons of ways to do this depending on what the actual application is.

If you really want us to help you with this, you must explain a little further and show some sample code with an image in it.