the function works well, however my experience has been that if you actually want the returned value (ie - html tag string) to be output to the generated page:
also, users of this function should keep in mind that the image is merely resized graphically (ie: force-fit). if the original image is 300kb or 1mb, the “thumbnail” will be just as large in terms of download size.
all this function does is change the width and height in php, cmon man, a whole page dedicated to changing the width and height to be sent back ? you can do that manually or using js, a real useful function would be ACTUALLY resizing the image. so you can load say your original digital 5mb file size of all your socks ina folder, and php will take it and resize them to display and actually resize the image so the browser doesnt download 5mb size thumbnails forever
this page acting like resizing the width= and height= value is so complicated… cmon man…
For Greater Justice. Since the code in this article is not likely to be used in production here is a function that will resize an image in to a given X (width) and Y (height) value. This function requires the GD extension to be installed.
$dst is optional, if left null it will overwrite the original file. Keep in mind there is no error checking in this function and will only work if the file type is a GIF, PNG or JPG. It should give one a general idea of how to go about resizing an image file with PHP.
Any reason why this might not be working in IE? I can get it to work fine in Firefox. Would it be the functions itself being the problem or is PHP not affected meaning it could just be an html error?
I want to use this function in a dynamic page ie. the images are loaded from a database using a php script so I can’t use the print function to display the image as suggested in prevoius threads. anyone know how to achieve this…
I’ve put the main part of the code below,
echo "<table class=\\"table_test\\">\
";
}//end of first if
//Display each record
echo "<tr>\
";
//get the image size of the picture and load it into an array
$mysock = getimagesize("rivcms/news/images/image_{$row['upload_id']}06.jpg");
//display the resized image on the screen.
echo "<td><img src=\\"rivcms/news/images/image_{$row['upload_id']}06.jpg\\" WHAT DO I DO HERE imageResize($mysock[0], $mysock[1], 75) />\
";
echo "<td>{$row['t']}</td>\
";
echo "<td>{$row['d']}</td>\
";
echo "</tr>\
";
$first = FALSE; //One record has been returned
}
hey guys…
i’m wondering if there is any good way to resize a bmp image with php
i’m using imagewbmp from the gd library but all i’m getting a a black resized image…
I have a question. I have images stored in a mysql database. When I retrieve them, they’re given a URL like getimg.php?id=23243, for example, of course. I found this script does not return the right information for images that do not end in a file name. Is there any modification I can use for the function to get it working with a databased image? Please email me ASAP, csmi27 at gmail dot com, as I probably won’t check back here often. Thanks!
#this will print a new row for each photo…
echo "
<tr>
<td align=\“center\”><img src=\“$url\” alt=\“\”><br>$url</td>
<td align=\“left\” valign=\“middle\”>$description</td>
</tr>";
}
// This is to close database
mysql_close($conn);
echo “</table>”;
?> [/COLOR]
I’ve used this script - thank you. I’m however having a problem with the images that are larger than the parameter passed in the function. These are photographs which are quite large. When I try to browse to the images folder to view the image I get a message stating “The image “resize.jpg” cannot be displayed, because it contains errors.”