Organize and display photo EXIF information

Source: Internet
Author: User
Tags foreach manual file size php code
Display the photo EXIF information in Chinese style, showing the sketch in the picture

This thing in addition to some PHP forum to display a simple 32 information, other people's lb5000 forum to see the show, ASP also has a long time did not touch looking dizzy.

Do not want to repeat the work, search Google, in addition to the ASP did not find other open source display Exif, so the collation out may be useful.

No technical content, basically just Chinese and data collation work, the following code for the main part, all files in the compression package, can be widely used in albums and forums to display picture information plug-ins, want to be familiar with the relevant knowledge of the friend to find bugs or to optimize.

There should be a lot of information to be needed at this time, if used alone should suffice.

——————————————————
I've seen pictures of people coming in with thumbnails, Photoshop, but I don't know how to add them, anybody know?

Thumbnails can be displayed:)


PHP Code:--------------------------------------------------------------------------------

?
/**
* function to get image information
*
* A function to obtain image information in a comprehensive way
*
* @access Public
* @param string $img picture 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", "rig HT 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 point average metering",
"3" => "point Test",
"4" => "zoning",
"5" => "Evaluation",
"6" => "local",
"255" => "other"
);
$Lightsource _arr = Array (
"0" => "Unknown",
"1" => "Daylight",
"2" => "fluorescent",
"3" => "tungsten",
"Ten" => "Flash",
"=>" "standard lighting a",
"=>" "Standard light B",
"=>" "Standard light C",
"=>", "D55",
"=>", "D65",
"=>", "D75",
"255" => "other"
);
$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 Picture exif information");
}
Else
{
$exif = Exif_read_data ($img, 0,true);
$new _img_info = Array (
"File Information" => "-----------------------------",
"FileName" => $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 [$exif [Ifd0][resolutionunit]],
"Vertical resolution" => $exif [ifd0][yresolution]. $ResolutionUnit [$exif [Ifd0][resolutionunit]],
"Create software" => $exif [Ifd0][software],
The Modify time => $exif [Ifd0][datetime],
"Author" => $exif [Ifd0][artist],
"YCbCr position Control" => $YCbCrPositioning [$exif [ifd0][ycbcrpositioning]],
"Copyright" => $exif [Ifd0][copyright],
"Photographic 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),
"Filming Time" => $exif [exif][datetimeoriginal],
"Digitized Time" => $exif [exif][datetimedigitized],
"Shooting high resolution" => $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],
"Max Aperture value" => "F". $exif [Exif][maxaperturevalue],
"Exposure Time" => $exif [Exif][exposuretime],
"F-Number" => $exif [Exif][fnumber],
"Metering Mode" => getimageinfoval ($exif [Exif][meteringmode], $MeteringMode _arr),
"Light source" => getimageinfoval ($exif [Exif][lightsource], $Lightsource _arr),
"Flash" => 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), 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][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. 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],
The user comment => $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 "),
"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></tr>";
}

$innerhtml. = "<tr><td colspan=\" 2\ ">";
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. = "</TD></TR></TABLE>";
?>
<title> Picture Information </title>
<meta http-equiv= "Content-type" content= "text/html; charset=?????? " >
<body>
<SCRIPT>
<!--
Initializing content values
parent.followtd<?=$_get[' r_id '];? >.innerhtml= ' <?= $innerhtml;? > ';
has been read
parent.document.images.followimg<?=$_get[' r_id '];? >.loaded= ' yes ';
-->
</SCRIPT>
</body>



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.