Get the width and height of an image using a function in PHP


/ Published in: PHP
Save to your folder(s)

When you run this script you will see the result like this

Image width 379
Image height 344
Image type 2
Image attribute width="379" height="344"

You will get the width, height, type of an image and also attribute of an image, I use this function in my image upload form.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. list($width, $height, $type, $attr) = getimagesize("image_name.jpg");
  4.  
  5. echo "Image width " .$width;
  6. echo "<BR>";
  7. echo "Image height " .$height;
  8. echo "<BR>";
  9. echo "Image type " .$type;
  10. echo "<BR>";
  11. echo "Attribute " .$attr;
  12.  
  13. ?>

URL: http://www.phpeasystep.com/workshopview.php?id=25

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.