Get image dimensions with php

DorthyKleiner

New Member
I'm trying to echo the width and height of an image into a looping array I have. Everything other than the width and height seems to be there. The images are displayed in a carousel that I have. For the carousel to work properly it likes to have the image width and height. I don't want to enter manual values and distort the images!!Here is a snippet of my code. \[code\] <?php do { $image = $_SERVER['DOCUMENT_ROOT'].$row_rs_imgpath['userimagespath'].$row_rs_smimg['thumbfile']; $x= imagesx($image); $y = imagesy($image); ?> <img src="http://stackoverflow.com/questions/14465997/<?php echo $row_rs_imgpath['userimagespath'].$row_rs_smimg['thumbfile']; ?>" alt="<?php echo $row_rs_smimg['imgname']; ?>" width="<?php echo $x;?>" height="<?php echo $y;?>" /> <?php } while ($row_rs_smimg = mysql_fetch_assoc($rs_smimg)); ?>\[/code\]And when you view the page source code you get the following:\[code\]<img src="http://stackoverflow.com/images/uploads/my-future-car-1358783315_thumb.jpg"width="" height="" /><img src="http://stackoverflow.com/images/uploads/albert_docks_liverpool-1358872736_thumb.jpg" width="" height="" />\[/code\]I have also tried\[code\]list($width, $height)= getimagesize($image);\[/code\]but that doesn't work either. Any ideas would be appreciated!
 
Back
Top