wxpsadd Posted November 10, 2008 Share Posted November 10, 2008 hi guys, i'm stuck in these problem where i want to resize an image if its larger than my standard size. so i tried to display those image attributes like width and height using javascript. but sad to say, only the last record on mysql displays the attributes. if only it would display the image attributes on all the records it would be easy to compare if my images are larger or on standard sizes. can someone help me on this? or is there any other way i can resize compare image sizes? i used these simple code below: $sql = "select * from tbl"; result = mysql_query($sql); echo '<form name=form1">'; echo '<table width="500">'; while($row=mysql_fetch_assoc($result)){ //javascript echo ' <script> window.onload=imgs; function imgs() { var imageheight'.$row["name"].'; var imagewidth'.$row["name"].'; imageheight'.$row["name"].' = document.form1.pic_'.$row["name"].'.height; imagewidth'.$row["name"].' = document.form1.pic_'.$row["name"].'.width; document.form1.iheight'.$row["name"].'.value = imageheight'.$row["name"].' document.form1.iwidth'.$row["name"].'.value = imagewidth'.$row["name"].' } </script> '; echo '<tr>'; echo '<td>'; echo '<img src="'.$row["image"].'.jpg" name="pic_'.$row["image"].'">'; echo '<input type="text" name="iheight'.$row["name"].'">'; echo '<input type="text" name="iwidth'.$row["name"].'">'; echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</form>'; Link to comment https://forums.phpfreaks.com/topic/132092-image-resize/ Share on other sites More sharing options...
cooldude832 Posted November 10, 2008 Share Posted November 10, 2008 Use http://us3.php.net/manual/en/function.getimagesize.php and use a style for that img tag or the classic width= height= on the img tag A lot simpler IMHO Just remember to scale down proportionally so you don't skew an image out of its WXL Ratio Link to comment https://forums.phpfreaks.com/topic/132092-image-resize/#findComment-686486 Share on other sites More sharing options...
wxpsadd Posted November 10, 2008 Author Share Posted November 10, 2008 thanks a lot it works~ i used the code below <?php $itemimage = array_values(getimagesize('../images/'.$row["name"].'.jpg')); list($height) = $itemimage; echo $height; ?> it does help to keep me away from javascript LOL Link to comment https://forums.phpfreaks.com/topic/132092-image-resize/#findComment-686506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.