corillo181 Posted June 18, 2006 Share Posted June 18, 2006 is there any way i can get the height and width of a image? Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/ Share on other sites More sharing options...
AndyB Posted June 18, 2006 Share Posted June 18, 2006 if it's already on your server - the getimagesize() function. Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-46986 Share on other sites More sharing options...
corillo181 Posted June 18, 2006 Author Share Posted June 18, 2006 under wher ein php info would i find that?cuz i tthink is if i had gd? and my server doi try this but it does not work.[code]<?php function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } include 'includes/db.php';$query=mysql_query("SELECT path FROM tra_cotm_photo")or die("error: ".mysql_error());$path=mysql_fetch_array($query);$test = getimagesize("../cotm/457565197.jpg"); ?><img src="../cotm/457565197.jpg" <?php imageResize($test[0],$test[1], 110); ?> />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-46988 Share on other sites More sharing options...
AndyB Posted June 18, 2006 Share Posted June 18, 2006 If you have the GD library installed, it's clearly visible in phpinfo (it has its own section of information).If you have GD installed and your code "doesn't work", there something not right wih your code. What is (not) happening with that script that makes you think there's a problem? Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-46993 Share on other sites More sharing options...
corillo181 Posted June 18, 2006 Author Share Posted June 18, 2006 tha tpage does nto resize with the function made.. so i think the imagesiz eit's not doign the workand yes the gd is on..plus i try using [code]<img src="image/123.jpg" atl="<?php getimagesize("image/123.jpg");?>">[/code]to see if it would show me the image size but it doesn't.. Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-46995 Share on other sites More sharing options...
AndyB Posted June 18, 2006 Share Posted June 18, 2006 getimagesize returns an array of values. Try this:[code]$size = getimagesize("image/123.jpg");echo "<img src='". image/123.jpg' ". $size[3]. ">";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-47026 Share on other sites More sharing options...
corillo181 Posted June 18, 2006 Author Share Posted June 18, 2006 mm that code is wrong and i dont see how tha tis going to tell me in any way if the #size is working. Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-47134 Share on other sites More sharing options...
AndyB Posted June 18, 2006 Share Posted June 18, 2006 Sorry, try this:[code]$size = getimagesize("image/123.jpg");echo "<img src='image/123.jpg' ". $size[3]. ">";[/code]If GD is working and if image/123.jpg exists (it's your example, so I assume it would), then $size[3] will display the width and height of the image - exactly what it says in the php manual. Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-47140 Share on other sites More sharing options...
corillo181 Posted June 19, 2006 Author Share Posted June 19, 2006 this worked..i got the hang of it.. thanx[code]$filename = 'images/123.jpg';$size = getimagesize("images/123.jpg");$width=$size[0];$height=$size[1];if($width >100 || $height >100){$n_w=$width / 2;$n_h=$height / 2;echo '<img src="images/123.jpg" width="'.$n_w.'" height="'.$n_h.'" />';}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12301-image/#findComment-47290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.