read_exif_data()函数是PHP中的内置函数,用于从图像文件读取EXIF标头,并且是exif_read_data()的替代函数。
用法:
array read_exif_data( mixed $stream, string $sections,
bool $arrays, bool $thumbnail )
参数:该函数接受上述和以下所述的四个参数:
- $stream:它指定图像文件。
- $sections (Optional):它指定用逗号分隔的部分列表。
- $arrays (Optional):它指定是否不将每个部分显示为数组。
- $thumbnail (Optional):它指定是否读取缩略图。
返回值:如果成功,则此函数返回关联数组;如果失败,则返回FALSE。
以下示例说明了PHP中的read_exif_data()函数:
范例1:
<?php
// Open a the file from local folder
$fp = fopen('./geeksforgeeks.jpg', 'rb');
// Read the exif headers
$headers = read_exif_data($fp);
// Print the headers
echo 'EXIF Headers:' . '<br>';
print("<pre>".print_r($headers, true)."</pre>");
?>输出:
EXIF Headers:
Array
(
[FileName] => geeksforgeeks.jpg
[FileDateTime] => 1580889002
[FileSize] => 17763
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] =>
[COMPUTED] => Array
(
=> width="667" height="184"
[Height] => 184
[Width] => 667
[IsColor] => 1
)
)
范例2:
<?php
// Create an Imagick Object
$image = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/20200123100652/geeksforgeeks12.jpg');
// Add comment to the image
$image->commentImage("THIS IS MY COMMENT");
// Save the file to local image
$image->writeImage('geeksforgeeks.jpg');
// Open a the same file
$fp = fopen('./geeksforgeeks.jpg', 'rb');
// Read the exif headers
$headers = read_exif_data($fp, 'COMMENT', true, true);
// Print the headers
echo 'EXIF Headers:' . '<br>';
print("<pre>".print_r($headers['COMMENT'], true)."</pre>");
?>输出:
EXIF Headers:
Array
(
[0] => THIS IS MY COMMENT
)
参考: https://www.php.net/manual/en/function.read-exif-data.php
相关用法
- d3.js d3.lab()用法及代码示例
- PHP exp()用法及代码示例
- PHP Ds\Map put()用法及代码示例
- d3.js d3.hcl()用法及代码示例
- PHP sin( )用法及代码示例
- PHP abs()用法及代码示例
- PHP cos( )用法及代码示例
- PHP tan( )用法及代码示例
- d3.js d3.map.set()用法及代码示例
- PHP next()用法及代码示例
- PHP Ds\Map get()用法及代码示例
- d3.js d3.sum()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | read_exif_data() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
