A method for displaying photo exif information in PHP _php tips

Source: Internet
Author: User
Tags php programming

PHP programming enables you to display photo exif information and display thumbnail effects in the picture, with the following code:

? /** * Functions to obtain image information * A function to obtain image information completely * @access public * @param string $img picture path * @return Array/function Getimageinfoval ($Im
  Ageinfo, $val _arr) {$InfoVal = "unknown";
      foreach ($val _arr as $name => $val) {if ($name = = $ImageInfo) {$InfoVal = & $val;
    Break
} return $InfoVal; function Getimageinfo ($img) {$imgtype = Array ("", "GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "TIFF" (Intel byte or
  Der) "," TIFF (Motorola byte order), "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM"); $Orientation = Array ("", "top left Side", "top right side", "bottom right side", "bottom left side", "left side top",
  "Right side Top", "right Side Bottom", "left Side Bottom");
  $ResolutionUnit = Array ("", "" "," inch "," cm ");
  $YCbCrPositioning = Array ("", "the center of Pixel Array", "The Datum point");
  $ExposureProgram = Array ("Undefined", "manual", "standard procedure", "Aperture precedent", "shutter precedent", "preliminary", "Motion Mode", "Portrait Mode", "landscape mode");
 $MeteringMode _arr = Array ("0" => "Unknown",   "1" => "average", "2" => "Central average Metering", "3" => "Point Measurement", "4" => "Zoning", "5" => "assessment
  "," 6 "=>" local "," 255 "=>" other "); $Lightsource _arr = Array ("0" => "Unknown", "1" => "Daylight", "2" => "Fluorescent", "3" => "tungsten wire  Lamp "," => "flash", "=>" "standard lighting a", "=>" standard light B "," => "standard lighting C", "the" =>
  "D55", "=>", "D65", "=>" "D75", "255" => "other"); $Flash _arr = Array ("0" => "Flash did not Fire", "1" => "Flash Fired", "5" => "Flas"
  
  H fired but strobe return light not Detected "," 7 "=>" Flash fired and strobe return light detected ",);
  $exif = Exif_read_data ($img, "IFD0");
  if ($exif ===false) {$new _img_info = array ("File information" => "no Picture exif information");
    else {$exif = Exif_read_data ($img, 0,true); $new _img_info = Array ("File information =>"-----------------------------, file name => $exif [file][filename], file type => $imgtype [$exif [File][filetype ], "file format" => $exif [file][mimetype], File size => $exif [file][filesize], timestamp => date  ("Y-m-d h:i:s", $exif [File][filedatetime]), "image Information" => "-----------------------------", "Picture description" => $exif [Ifd0][imagedescription], "Manufacturer" => $exif [Ifd0][make], "model" => $exif [Ifd0][model], " Direction "=> $Orientation [$exif [ifd0][orientation]]," Horizontal resolution "=> $exif [ifd0][xresolution]. $ResolutionUnit [$ex
      If[ifd0][resolutionunit]], "vertical resolution" => $exif [ifd0][yresolution]. $ResolutionUnit [$exif [Ifd0][resolutionunit]], "Create software" => $exif [Ifd0][software], "Modify Time" => $exif [Ifd0][datetime], "author" => $exif [IFD 0][artist], "YCbCr position control" => $YCbCrPositioning [$exif [ifd0][ycbcrpositioning]], "copyright" => $exif [IFD0] [copyright], "photography rights"=> $exif [Computed][copyright.photographer]," edit copyright "=> $exif [Computed][copyright.editor]," shooting information  "=>"-----------------------------, "Exif version" => $exif [exif][exifversion], "FlashPix version" => "Ver." Number_format ($exif [exif][flashpixversion]/100,2), "Filming Time" => $exif [exif][datetimeoriginal], "number Character time "=> $exif [exif][datetimedigitized]," Shoot resolution High "=> $exif [computed][height]," Shoot resolution width "=> $exif [Computed]
      [Width],/* The actual aperture value of lens when the image is taken.
      Unit is APEX.
      To convert this value to ordinary f-number (f-stop) Calculate this value ' s power of Root 2 (=1.4142).
      For example, if the Aperturevalue was ' 5 ', f-number is pow (1.41425,5) = F5.6.    * * "aperture" => $exif [Exif][aperturevalue], "shutter speed" => $exif [Exif][shutterspeedvalue], "Shutter aperture" => $exif [Computed][aperturefnumber], "Maximum aperture value" => "F". $exIf[exif][maxaperturevalue], "Exposure time" => $exif [Exif][exposuretime], "f-number" => $exif [Exif][fnumb ER], "photometric mode" => getimageinfoval ($exif [Exif][meteringmode], $MeteringMode _arr), "light source" => Getimagei 
      Nfoval ($exif [Exif][lightsource], $Lightsource _arr), "Flash" => getimageinfoval ($exif [Exif][flash], $Flash _arr), "Exposure mode" => ($exif [exif][exposuremode]==1?) Manual ": Auto"), "White balance" => ($exif [exif][whitebalance]==1?] Manual ": Automatic"), "exposure program" => $ExposureProgram [$exif [Exif][exposureprogram]],/* Brightness of taken Subje CT, Unit is APEX.
      To calculate exposure (EV) from Brigtnessvalue (BV), for you must add Sensitivityvalue (SV). 
      EV=BV+SV Sv=log ((isospeedrating/3.125), 2) iso100:sv=5, iso200:sv=6, iso400:sv=7, iso125:sv=5.32. * * "exposure compensation" => $exif [Exif][exposurebiasvalue]. " EV ", ISO-sensitivity" => $exif [exif][isospeedratings], "Component Configuration" => (Bin2Hex ($exif [exif][componentsConfiguration] = = "01020300"? YCbCr ":" RGB "),//' 0x04,0x05,0x06,0x00 ' =" RGB "' 0x01,0x02,0x03,0x00 ' =" YCbCr "" image compression rate "=> $exif [exif][compressedbits Perpixel]. " Bits/pixel "," Focus distance "=> $exif [computed][focusdistance]." M "," focal length "=> $exif [exif][focallength]." MM "," equivalent 35mm focal length "=> $exif [exif][focallengthin35mmfilm]." MM ",/* Stores user comment. This tag allows to use Two-byte character code or Unicode. The 8 bytes describe the character code.
      ' JIS ' is a Japanese character code (known as kanji). ' 0x41,0x53,0x43,0x49,0x49,0x00,0x00,0x00 ': ASCII ' 0x4a,0x49,0x53,0x00,0x00,0x00,0x00,0x00 ': JIS ' 0x55,0x4e,0x49,   0x43,0x4f,0x44,0x45,0x00 ': Unicode ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ': Undefined/"User annotation encoding" => $exif [computed][usercommentencoding], "user annotations" => $exif [computed][usercomment], "Color space" => ($exif [EXIF] [Colorspace]==1?] SRGB ":" uncalibrated ")," Exif image width "=> $exif [exif][Exifimagelength], "EXIF image height" => $exif [exif][exifimagewidth], "File source" => (Bin2Hex ($exif [Exif][fileso Urce]) ==0x03? " Digital still Camera ": Unknown"), "Scene type" => (Bin2Hex ($exif [exif][scenetype]) ==0x01? "  A directly photographed image ": Unknown"), "thumbnail file format" => $exif [Computed][thumbnail.filetype], "Thumbnail MIME format"
  => $exif [Computed][thumbnail.mimetype]);
return $new _img_info;
} $innerhtml = "";
$exif = Getimageinfo ($_get[' img '));

$innerhtml. = "<TABLE>"; foreach ($exif as $name => $val) {$innerhtml. = "<tr><td>{$name}</td><td>{$val}</td>&
Lt;/tr> ";
$innerhtml. = "<tr><td colspan=\" 2\ ">"; if ($_get[' img ']) {$image = Exif_thumbnail ($_get[' img '));} else {$image = false;} if ($image!==false) {$innerht ml. = "</TR></TABLE>"?>  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.