PHP获取图片exif属性信息的方法
<?php<br />/**<br />* 获取图象信息的函数<br />*<br />* 一个全面获取图象信息的函数<br />*<br />* @access public<br />* @param string $img 图片路径<br />* @return array<br />*/<br />function GetImageInfoVal($ImageInfo,$val_arr) {<br /> $InfoVal = "未知";<br /> foreach($val_arr as $name=>$val) {<br /> if ($name==$ImageInfo) {<br /> $InfoVal = &$val;<br /> break;<br /> }<br /> }<br /> return $InfoVal;<br />}<br />function GetImageInfo($img) {<br /> <br /> <br /> <br /> $imgtype = array("", "GIF", "JPG", "PNG", "SWF", "PSD", "BMP", "TIFF(intel byte order)", "TIFF(motorola byte order)", "JPC", "JP2", "JPX", "JB2", "SWC", "IFF", "WBMP", "XBM");<br /> $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");<br /> $ResolutionUnit = array("", "", "英寸", "厘米");<br /> $YCbCrPositioning = array("", "the center of pixel array", "the datum point");<br /> $ExposureProgram = array("未定义", "手动", "标准程序", "光圈先决", "快门先决", "景深先决", "运动模式", "肖像模式", "风景模式");<br /> $MeteringMode_arr = array(<br /> "0" => "未知",<br /> "1" => "平均",<br /> "2" => "中央重点平均测光",<br /> "3" => "点测",<br /> "4" => "分区",<br /> "5" => "评估",<br /> "6" => "局部",<br /> "255" => "其他"<br /> );<br /> $Lightsource_arr = array(<br /> "0" => "未知",<br /> "1" => "日光",<br /> "2" => "荧光灯",<br /> "3" => "钨丝灯",<br /> "10" => "闪光灯",<br /> "17" => "标准灯光A",<br /> "18" => "标准灯光B",<br /> "19" => "标准灯光C",<br /> "20" => "D55",<br /> "21" => "D65",<br /> "22" => "D75",<br /> "255" => "其他"<br /> );<br /> $Flash_arr = array(<br /> "0" => "flash did not fire",<br /> "1" => "flash fired",<br /> "5" => "flash fired but strobe return light not detected",<br /> "7" => "flash fired and strobe return light detected",<br /> );<br /> <br /> $exif = exif_read_data ($img,"IFD0");<br /> if ($exif===false) {<br /> $new_img_info = array ("文件信息" => "没有图片EXIF信息");<br /> }<br /> else<br /> {<br /> $exif = exif_read_data ($img,0,true);<br /> $new_img_info = array (<br /> "文件信息" => "-----------------------------",<br /> "文件名" => $exif[FILE][FileName],<br /> "文件类型" => $imgtype[$exif[FILE][FileType]],<br /> "文件格式" => $exif[FILE][MimeType],<br /> "文件大小" => $exif[FILE][FileSize],<br /> "时间戳" => date("Y-m-d H:i:s",$exif[FILE][FileDateTime]),<br /> "图像信息" => "-----------------------------",<br /> "图片说明" => $exif[IFD0][ImageDescription],<br /> "制造商" => $exif[IFD0][Make],<br /> "型号" => $exif[IFD0][Model],<br /> "方向" => $Orientation[$exif[IFD0][Orientation]],<br /> "水平分辨率" => $exif[IFD0][XResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]],<br /> "垂直分辨率" => $exif[IFD0][YResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]],<br /> "创建软件" => $exif[IFD0][Software],<br /> "修改时间" => $exif[IFD0][DateTime],<br /> "作者" => $exif[IFD0][Artist],<br /> "YCbCr位置控制" => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]],<br /> "版权" => $exif[IFD0][Copyright],<br /> "摄影版权" => $exif[COMPUTED][Copyright.Photographer],<br /> "编辑版权" => $exif[COMPUTED][Copyright.Editor],<br /> "拍摄信息" => "-----------------------------",<br /> "Exif版本" => $exif[EXIF][ExifVersion],<br /> "FlashPix版本" => "Ver. ".number_format($exif[EXIF][FlashPixVersion]/100,2),<br /> "拍摄时间" => $exif[EXIF][DateTimeOriginal],<br /> "数字化时间" => $exif[EXIF][DateTimeDigitized],<br /> "拍摄分辨率高" => $exif[COMPUTED][Height],<br /> "拍摄分辨率宽" => $exif[COMPUTED][Width],<br /> /*<br /> The actual aperture value of lens when the image was taken.<br /> Unit is APEX.<br /> To convert this value to ordinary F-number(F-stop),<br /> calculate this value's power of root 2 (=1.4142).<br /> For example, if the ApertureValue is '5', F-number is pow(1.41425,5) = F5.6.<br /> */<br /> "光圈" => $exif[EXIF][ApertureValue],<br /> "快门速度" => $exif[EXIF][ShutterSpeedValue],<br /> "快门光圈" => $exif[COMPUTED][ApertureFNumber],<br /> "最大光圈值" => "F".$exif[EXIF][MaxApertureValue],<br /> "曝光时间" => $exif[EXIF][ExposureTime],<br /> "F-Number" => $exif[EXIF][FNumber],<br /> "测光模式" => GetImageInfoVal($exif[EXIF][MeteringMode],$MeteringMode_arr),<br /> "光源" => GetImageInfoVal($exif[EXIF][LightSource], $Lightsource_arr),<br /> "闪光灯" => GetImageInfoVal($exif[EXIF][Flash], $Flash_arr),<br /> "曝光模式" => ($exif[EXIF][ExposureMode]==1?"手动":"自动"),<br /> "白平衡" => ($exif[EXIF][WhiteBalance]==1?"手动":"自动"),<br /> "曝光程序" => $ExposureProgram[$exif[EXIF][ExposureProgram]],<br /> /*<br /> Brightness of taken subject, unit is APEX. To calculate Exposure(Ev) from BrigtnessValue(Bv), you must add SensitivityValue(Sv).<br /> Ev=Bv+Sv Sv=log((ISOSpeedRating/3.125),2)<br /> ISO100:Sv=5, ISO200:Sv=6, ISO400:Sv=7, ISO125:Sv=5.32. <br /> */<br /> "曝光补偿" => $exif[EXIF][ExposureBiasValue]."EV",<br /> "ISO感光度" => $exif[EXIF][ISOSpeedRatings],<br /> "分量配置" => (bin2hex($exif[EXIF][ComponentsConfiguration])=="01020300"?"YCbCr":"RGB"),//'0x04,0x05,0x06,0x00'="RGB" '0x01,0x02,0x03,0x00'="YCbCr"<br /> "图像压缩率" => $exif[EXIF][CompressedBitsPerPixel]."Bits/Pixel",<br /> "对焦距离" => $exif[COMPUTED][FocusDistance]."m",<br /> "焦距" => $exif[EXIF][FocalLength]."mm",<br /> "等价35mm焦距" => $exif[EXIF][FocalLengthIn35mmFilm]."mm",<br /> /*<br /> 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).<br /> '0x41,0x53,0x43,0x49,0x49,0x00,0x00,0x00':ASCII<br /> '0x4a,0x49,0x53,0x00,0x00,0x00,0x00,0x00':JIS<br /> '0x55,0x4e,0x49,0x43,0x4f,0x44,0x45,0x00':Unicode<br /> '0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00':Undefined<br /> */<br /> "用户注释编码" => $exif[COMPUTED][UserCommentEncoding],<br /> "用户注释" => $exif[COMPUTED][UserComment],<br /> "色彩空间" => ($exif[EXIF][ColorSpace]==1?"sRGB":"Uncalibrated"),<br /> "Exif图像宽度" => $exif[EXIF][ExifImageLength],<br /> "Exif图像高度" => $exif[EXIF][ExifImageWidth],<br /> "文件来源" => (bin2hex($exif[EXIF][FileSource])==0x03?"digital still camera":"unknown"),<br /> "场景类型" => (bin2hex($exif[EXIF][SceneType])==0x01?"A directly photographed image":"unknown"),<br /> "缩略图文件格式" => $exif[COMPUTED][Thumbnail.FileType],<br /> "缩略图Mime格式" => $exif[COMPUTED][Thumbnail.MimeType]<br /> );<br /> }<br /> return $new_img_info;<br />}<br /> <br />$innerhtml = "";<br />$exif = GetImageInfo($_GET['img']);<br />$innerhtml .= "<TABLE>";<br /> <br />foreach($exif as $name=>$val) {<br /> $innerhtml .= "<TR><TD>{$name}</TD><TD>{$val}</TD></TR>";<br />}<br /> <br />$innerhtml .= "<TR><TD colspan=\"2\">";<br />if ($_GET['img']) {<br /> $image = exif_thumbnail($_GET['img']);<br />} else {<br /> $image = false;<br />}<br />if ($image!==false) {<br /> $innerhtml .= "<img src=\"thumbnail.php?img=".$_GET['img']."\" alt="PHP获取图片exif属性信息的方法" >";<br />} else {<br /> // no thumbnail available, handle the error here<br /> $innerhtml .= "No thumbnail available";<br />}<br /> <br />$innerhtml .= "</TD></TR></TABLE>";<br />?><br /><html><br /><head> <br /><title>图片信息</title><br /><meta http-equiv="Content-Type" content="text/html; charset=??????"><br /></head><br /><body><br /><SCRIPT><br /><!--<br />//初始化内容值<br />parent.followTd<?=$_GET['r_id'];?>.innerHTML='<?=$innerhtml;?>';<br />//已读取<br />parent.document.images.followImg<?=$_GET['r_id'];?>.loaded='yes';<br />--><br /></SCRIPT><br /></body><br /></html>

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.

Fibers was introduced in PHP8.1, improving concurrent processing capabilities. 1) Fibers is a lightweight concurrency model similar to coroutines. 2) They allow developers to manually control the execution flow of tasks and are suitable for handling I/O-intensive tasks. 3) Using Fibers can write more efficient and responsive code.

The PHP community provides rich resources and support to help developers grow. 1) Resources include official documentation, tutorials, blogs and open source projects such as Laravel and Symfony. 2) Support can be obtained through StackOverflow, Reddit and Slack channels. 3) Development trends can be learned by following RFC. 4) Integration into the community can be achieved through active participation, contribution to code and learning sharing.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function