⑴ 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');
?>