PHPå®ç°æ¾ç¤ºç §çexifä¿¡æ¯çæ¹æ³_PHPæç¨
程序员文章站
2022-05-01 13:34:18
...
PHPå®ç°æ¾ç¤ºç §çexifä¿¡æ¯çæ¹æ³
PHPç¼ç¨å¯å®ç°æ¾ç¤ºç §çEXIFä¿¡æ¯ï¼æ¾ç¤ºå¾çä¸ç¼©ç¥å¾ææï¼å ¶ä»£ç å¦ä¸ï¼
/** * è·åå¾è±¡ä¿¡æ¯çå½æ° * ä¸ä¸ªå ¨é¢è·åå¾è±¡ä¿¡æ¯çå½æ° * @access public * @param string $img å¾çè·¯å¾ * @return array */ function GetImageInfoVal($ImageInfo,$val_arr) { $InfoVal = "æªç¥"; 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 order)", "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("", "", "è±å¯¸", "åç±³"); $YCbCrPositioning = array("", "the center of pixel array", "the datum point"); $ExposureProgram = array("æªå®ä¹", "æå¨", "æ åç¨åº", "å åå å³", "å¿«é¨å å³", "æ¯æ·±å å³", "è¿å¨æ¨¡å¼", "èå模å¼", "é£æ¯æ¨¡å¼"); $MeteringMode_arr = array( "0" => "æªç¥", "1" => "å¹³å", "2" => "ä¸å¤®éç¹å¹³åæµå ", "3" => "ç¹æµ", "4" => "ååº", "5" => "è¯ä¼°", "6" => "å±é¨", "255" => "å ¶ä»" ); $Lightsource_arr = array( "0" => "æªç¥", "1" => "æ¥å ", "2" => "è§å ç¯", "3" => "é¨ä¸ç¯", "10" => "éªå ç¯", "17" => "æ åç¯å A", "18" => "æ åç¯å B", "19" => "æ åç¯å C", "20" => "D55", "21" => "D65", "22" => "D75", "255" => "å ¶ä»" ); $Flash_arr = array( "0" => "flash did not fire", "1" => "flash fired", "5" => "flash 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 ("æ件信æ¯" => "没æå¾çEXIFä¿¡æ¯"); } else { $exif = exif_read_data ($img,0,true); $new_img_info = array ( "æ件信æ¯" => "-----------------------------", "æ件å" => $exif[FILE][FileName], "æ件类å" => $imgtype[$exif[FILE][FileType]], "æä»¶æ ¼å¼" => $exif[FILE][MimeType], "æ件大å°" => $exif[FILE][FileSize], "æ¶é´æ³" => date("Y-m-d H:i:s",$exif[FILE][FileDateTime]), "å¾åä¿¡æ¯" => "-----------------------------", "å¾ç说æ" => $exif[IFD0][ImageDescription], "å¶é å" => $exif[IFD0][Make], "åå·" => $exif[IFD0][Model], "æ¹å" => $Orientation[$exif[IFD0][Orientation]], "æ°´å¹³å辨ç" => $exif[IFD0][XResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]], "åç´å辨ç" => $exif[IFD0][YResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]], "å建软件" => $exif[IFD0][Software], "ä¿®æ¹æ¶é´" => $exif[IFD0][DateTime], "ä½è " => $exif[IFD0][Artist], "YCbCrä½ç½®æ§å¶" => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]], "çæ" => $exif[IFD0][Copyright], "æå½±çæ" => $exif[COMPUTED][Copyright.Photographer], "ç¼è¾çæ" => $exif[COMPUTED][Copyright.Editor], "ææä¿¡æ¯" => "-----------------------------", "Exifçæ¬" => $exif[EXIF][ExifVersion], "FlashPixçæ¬" => "Ver. ".number_format($exif[EXIF][FlashPixVersion]/100,2), "æææ¶é´" => $exif[EXIF][DateTimeOriginal], "æ°ååæ¶é´" => $exif[EXIF][DateTimeDigitized], "ææå辨çé«" => $exif[COMPUTED][Height], "ææå辨ç宽" => $exif[COMPUTED][Width], /* The actual aperture value of lens when the image was 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 is '5', F-number is pow(1.41425,5) = F5.6. */ "å å" => $exif[EXIF][ApertureValue], "å¿«é¨é度" => $exif[EXIF][ShutterSpeedValue], "å¿«é¨å å" => $exif[COMPUTED][ApertureFNumber], "æ大å åå¼" => "F".$exif[EXIF][MaxApertureValue], "æå æ¶é´" => $exif[EXIF][ExposureTime], "F-Number" => $exif[EXIF][FNumber], "æµå 模å¼" => GetImageInfoVal($exif[EXIF][MeteringMode],$MeteringMode_arr), "å æº" => GetImageInfoVal($exif[EXIF][LightSource], $Lightsource_arr), "éªå ç¯" => GetImageInfoVal($exif[EXIF][Flash], $Flash_arr), "æå 模å¼" => ($exif[EXIF][ExposureMode]==1?"æå¨":"èªå¨"), "ç½å¹³è¡¡" => ($exif[EXIF][WhiteBalance]==1?"æå¨":"èªå¨"), "æå ç¨åº" => $ExposureProgram[$exif[EXIF][ExposureProgram]], /* Brightness of taken subject, unit is APEX. To calculate Exposure(Ev) from BrigtnessValue(Bv), 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. */ "æå è¡¥å¿" => $exif[EXIF][ExposureBiasValue]."EV", "ISOæå 度" => $exif[EXIF][ISOSpeedRatings], "åéé ç½®" => (bin2hex($exif[EXIF][ComponentsConfiguration])=="01020300"?"YCbCr":"RGB"), //'0x04,0x05,0x06,0x00'="RGB" '0x01,0x02,0x03,0x00'="YCbCr" "å¾åå缩ç" => $exif[EXIF][CompressedBitsPerPixel]."Bits/Pixel", "对ç¦è·ç¦»" => $exif[COMPUTED][FocusDistance]."m", "ç¦è·" => $exif[EXIF][FocalLength]."mm", "çä»·35mmç¦è·" => $exif[EXIF][FocalLengthIn35mmFilm]."mm", /* Stores user comment. This tag allows to use two-byte character code or unicode. First 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 */ "ç¨æ·æ³¨éç¼ç " => $exif[COMPUTED][UserCommentEncoding], "ç¨æ·æ³¨é" => $exif[COMPUTED][UserComment], "è²å½©ç©ºé´" => ($exif[EXIF][ColorSpace]==1?"sRGB":"Uncalibrated"), "Exifå¾å宽度" => $exif[EXIF][ExifImageLength], "Exifå¾åé«åº¦" => $exif[EXIF][ExifImageWidth], "æ件æ¥æº" => (bin2hex($exif[EXIF][FileSource])==0x03?"digital still camera":"unknown"), "åºæ¯ç±»å" => (bin2hex($exif[EXIF][SceneType])==0x01?"A directly photographed image":"unknown"), "缩ç¥å¾æä»¶æ ¼å¼" => $exif[COMPUTED][Thumbnail.FileType], "缩ç¥å¾Mimeæ ¼å¼" => $exif[COMPUTED][Thumbnail.MimeType] ); } return $new_img_info; } $innerhtml = ""; $exif = GetImageInfo($_GET['img']); $innerhtml .= ""; foreach($exif as $name=>$val) { $innerhtml .= "
"; ?>"; } $innerhtml .= " {$name} {$val} "; if ($_GET['img']) { $image = exif_thumbnail($_GET['img']); } else { $image = false; } if ($image!==false) { $innerhtml .= ""; } else { // no thumbnail available, handle the error here $innerhtml .= "No thumbnail available"; } $innerhtml .= " å¾çä¿¡æ¯