⑴ php如何读取照片的exif信息实现代码
<?php
/**
*读取jpeg图片的Exif信息
*$img为图片路径
*
*琼台博客
*/
functiongetExif($img){
$exif=exif_read_data($img,'IFD0');
returnarray(
'文件名'=>$exif['FileName'],
'器材品牌'=>$exif['Make'],
'器材'=>$exif['Model'],
'快门'=>$exif['ExposureTime'],
'光圈'=>$exif['FNumber'],
'焦距'=>$exif['FocalLength'],
'感光度'=>$exif['ISOSpeedRatings']
);
}
读取照片
<?php
$exifInfo=getExif('a.jpg');
echo'<pre>';
print_r($exifInfo);
echo'</pre>';
执行结果:
Array
(
[文件名]=>25556306.jpg
[器材品牌]=>NIKONCORPORATION
[器材]=>NIKOND3100
[快门]=>10/32000
[光圈]=>18/10
[焦距]=>350/10
[感光度]=>100
)
⑵ PHP上传图片时,如何exif_read_data获取exif
php获取
图片的exif信息,php自带一个exif_read_data函数可以用来读取图片的exif信息,代码来自php手册:
<?php
echo "test1.jpg:<br /> ";
$exif = exif_read_data('tests/test1.jpg', 'IFD0');
echo $exif===false ? "No header data found.<br /> " : "Image contains headers<br /> ";
$exif = exif_read_data('tests/test2.jpg', 0, true);
echo "test2.jpg:<br /> ";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br /> ";
}
}
?>
输出结果如下
test1.jpg:
Noheaderdatafound.
test2.jpg:
FILE.FileName:test2.jpg
FILE.FileDateTime:1017666176
FILE.FileSize:1240
FILE.FileType:2
FILE.SectionsFound:ANY_TAG,IFD0,THUMBNAIL,COMMENT
COMPUTED.html:
COMPUTED.Height:1
COMPUTED.Width:1
COMPUTED.IsColor:1
COMPUTED.ByteOrderMotorola:1
COMPUTED.UserComment:Exiftestimage.
COMPUTED.UserCommentEncoding:ASCII
COMPUTED.Copyright:Photo(c)M.Boerger,EditedbyM.Boerger.
COMPUTED.Copyright.Photographer:Photo(c)M.Boerger
COMPUTED.Copyright.Editor:EditedbyM.Boerger.
IFD0.Copyright:Photo(c)M.Boerger
IFD0.UserComment:ASCII
THUMBNAIL.JPEGInterchangeFormat:134
THUMBNAIL.JPEGInterchangeFormatLength:523
COMMENT.0:Comment#1.
COMMENT.1:Comment#2.
COMMENT.2:Comment#3end
THUMBNAIL.JPEGInterchangeFormat:134
THUMBNAIL.Thumbnail.Height:1
THUMBNAIL.Thumbnail.Height:1
⑶ php 怎么修改图片exif信息或者有没有其他的程序可以修改的
通过: 来修改。
教程看:这里
懒得打开的话就看这里
<?php
$image=newImagick();
$image->newImage(300,200,"black");
$image->setImageProperty('Exif:Make','Imagick');
echo$image->getImageProperty('Exif:Make');
?>