Posted By

Some0ne on 10/03/12


Tagged

width image type height attr


Versions (?)

Get the width, height, type and attr of an image


 / Published in: PHP
 

Just a rework of http://snipplr.com/view/7523/ with an added switch to change type number to extention name.

  1. list($width, $height, $type, $attr) = getimagesize('image_name.jpg');
  2.  
  3. /*
  4. 1 = GIF 5 = PSD 9 = JPC 13 = SWC
  5. 2 = JPG 6 = BMP 10 = JP2 14 = IFF
  6. 3 = PNG 7 = TIFF(intel byte order) 11 = JPX 15 = WBMP
  7. 4 = SWF 8 = TIFF(motorola byte order) 12 = JB2 16 = XBM
  8. */
  9.  
  10. switch($type) {
  11. case 1: $typex = 'GIF'; break;
  12. case 2: $typex = 'JPG'; break;
  13. case 3: $typex = 'PNG'; break;
  14. case 4: $typex = 'SWF'; break;
  15. case 5: $typex = 'PSD'; break;
  16. case 6: $typex = 'BMP'; break;
  17. case 7: $typex = 'TIFF(intel byte order)'; break;
  18. case 8: $typex = 'TIFF(motorola byte order)'; break;
  19. case 9: $typex = 'JPC'; break;
  20. case 10: $typex = 'JP2'; break;
  21. case 11: $typex = 'JPX'; break;
  22. case 12: $typex = 'JB2'; break;
  23. case 13: $typex = 'SWC'; break;
  24. case 14: $typex = 'IFF'; break;
  25. case 15: $typex = 'WBMP'; break;
  26. case 16: $typex = 'XBM'; break;
  27. }
  28.  
  29. echo 'Width: ' . $width . '<br />Height: ' . $height . '<br />Type: ' . $typex . '<br />Attribute: ' . $attr;

Report this snippet  

You need to login to post a comment.