This article describes how to use PHP to display the exif information of a photo. For more information, see
This article describes how to use PHP to display the exif information of a photo. For more information, see
PHP programming allows you to display the EXIF information of a photo and display the thumbnail effect in the image. The Code is as follows:
<? /*** Function for obtaining image information * a function for fully obtaining image information * @ access public * @ param string $ img image path * @ return array */function GetImageInfoVal ($ ImageInfo, $ 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 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 ("", "", "inches", "centimeters "); $ YCbCrPositioning = array ("", "the center of pixel array", "the datum point"); $ ExposureProgram = array ("undefined", "Manual", "label Quasi-program "," aperture prerequisite "," Shutter prerequisite "," depth of field prerequisite "," motion mode "," portrait mode "," Landscape mode "); $ MeteringMode_arr = array ("0" => "unknown", "1" => "average", "2" => "central key average light measurement ", "3" => "test", "4" => "partition", "5" => "evaluation", "6" => "local ", "255" => "other"); $ Lightsource_arr = array ("0" => "unknown", "1" => "daylight ", "2" => "Fluorescent Lamps", "3" => "tungsten lamps", "10" => "Flashlight", "17" => "standard lamps ", "18" => "standard light B", "19" => "standard light C", "20" => "D55", "21" => "D65 ", "22" => "D75", "255" => "Others"); $ 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 ("File Information" => "no image 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" => "-----------------------------", "Image Description" => $ exif [IFD0] [ImageDescription], "manufacturer" =>$ exif [IFD0] [Make], "Model" =>$ exif [IFD0] [Model], "direction" => $ Orientation [$ exif [IFD0] [Orientation], "horizontal resolution" => $ exif [IFD0] [XResolution]. $ ResolutionU Nit [$ exif [IFD0] [ResolutionUnit], "vertical resolution" => $ exif [IFD0] [YResolution]. $ ResolutionUnit [$ exif [IFD0] [ResolutionUnit], "Create Software" => $ exif [IFD0] [Software], "modification time" => $ exif [IFD0] [DateTime], "author" => $ exif [IFD0] [Artist], "YCbCr location control" => $ YCbCrPositioning [$ exif [IFD0] [YCbCrPositioning], "Copyright" => $ exif [IFD0] [Copyright], "photography Copyright" => $ 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), "shooting time" => $ exif [EXIF] [DateTimeOriginal], "digitization time" => $ exif [EXIF] [DateTimeDigitized], "High shooting resolution" => $ exif [COMPUTED] [Height], "Shooting resolution Width" => $ exif [COMPUTED] [Width],/* The actual aperture value of lens when the image was taken. unit is APEX. to convert this value to or Dinary 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. */"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] [FNumber], "metering mode" => GetIm AgeInfoVal ($ exif [EXIF] [MeteringMode], $ MeteringMode_arr), "light source" => GetImageInfoVal ($ exif [EXIF] [LightSource], $ Lightsource_arr ), "Flashlight" => GetImageInfoVal ($ exif [EXIF] [Flash], $ Flash_arr), "exposure mode" => ($ exif [EXIF] [ExposureMode] = 1? "Manual": "automatic"), "White Balance" => ($ exif [EXIF] [WhiteBalance] = 1? "Manual": "automatic"), "exposure program" => $ 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 = log (ISO speedrating/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] [CompressedBitsPerPixel]. "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. 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, 0x00 ': JIS '0x55, 0x4e, 0x49,0x43, 0x4f, 0x44,0x45, 0x00': Unicode '0x00, 0 x, 0 x, 0 x, 0 x, 0 x, 0x00, 0x00': Undefined */"User annotation encoding" => $ exif [COMPUTED] [UserCommentEncoding], "user comments" => $ 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] [FileSource]) = 0x03? "Digital still camera": "unknown"), "scenario 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. ="
"; Foreach ($ exif as $ name => $ val) {$ innerhtml. ="
{$ Name} |
{$ Val} |
";}$ Innerhtml. ="
"; 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. =" |
";?> Image Information SCRIPT SCRIPT
,