Zubrag.com
October 21, 2019, 04:53:34 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to get image dimension in php (sample)  (Read 23301 times)
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« on: November 16, 2006, 04:05:30 AM »

Use GetImageSize function in ordert to get image size in php.

Syntax: array getimagesize ( string filename [, array &imageinfo] )

It returns
  • image width
  • image height
  • image type; 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
  • image size string to use in html <img> tag (sample: height="100" width="50")
  • some other image parameters, starting PHP 4.3.0

Cut from the php manual:
The optional imageinfo parameter allows you to extract some extended information from the image file. Currently, this will return the different JPG APP markers as an associative array. Some programs use these APP markers to embed text information in images. A very common one is to embed IPTC  http://www.iptc.org/ information in the APP13 marker. You can use the iptcparse()  function to parse the binary APP13 marker into something readable.

Code:
<?php
  $size 
GetImageSize("my-picture.jpg"$info);
  if (isset(
$info["APP13"])) {
    
$iptc iptcparse($info["APP13"]);
    
var_dump($iptc);
  }
  
$img_x $size[0];
  
$img_y $size[1];
  
$img_type  $size[2];
  
$img_sizes $size[3];
  
$channels $size['channels'];
  
$bits $size['bits'];
  
$mime $size['mime']; // delivers correct HTTP Content-type to be user in headers
  // sample:  header("Content-type: {$size['mime']}");

?>

Logged
basheer
Newbie
*
Posts: 6


« Reply #1 on: August 27, 2009, 11:24:26 PM »

what is the use of var_dump and var_export..
and tell the difference between them..
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC