int exif_imagetype ( string $filename )
1 imagetype_gif
2 imagetype_jpeg
3 imagetype_png
4 imagetype_swf
5 imagetype_ps教程d
6 imagetype_bmp
7 imagetype_tiff_ii (intel byte order)
8 imagetype_tiff_mm (motorola byte order)
9 imagetype_jpc
10 imagetype_jp2
11 imagetype_jpx
12 imagetype_jb2
13 imagetype_swc
14 imagetype_iff
15 imagetype_wbmp
16 imagetype_xbm
*/
$img="image.gif"; //定義文件
if(exif_imagetype($img)!=imagetype_gif) //判斷文件類型
{
echo "指定的圖片不是gif圖片"; //輸出結果
}
else
{
echo "指定的圖片是gif圖片";
}
/*
array exif_read_data ( string $filename [, string $sections = null [, bool $arrays = false [, bool $thumbnail = false ]]] )
*/
echo "test1.jpg:<br/>n"; //輸出文件名
$exif=exif_read_data('tests/test1.jpg','ifd0'); //讀取文件1信息
//根據結果判斷
echo $exif===false ? "no header data found.<br/>n":"image contains headers<br/>n";
$exif=exif_read_data('tests/test2.jpg',0,true); //讀取文件2信息
echo "test2.jpg:<br/>n"; //輸出文件名
foreach($exif as $key=>$section) //循環讀取信息
{
foreach($section as $name=>$val)
{
echo "$key.$name:$val<br/>n";
}
}
/*
test1.jpg:
no header data found.
test2.jpg:
file.filename: test2.jpg
file.filedatetime: 1017666176
file.filesize: 1240
file.filetype: 2
file.sectionsfound: any_tag, ifd0, thumbnail, comment
computed.html: width="1" height="1"
computed.height: 1
computed.width: 1
computed.iscolor: 1
computed.byteordermotorola: 1
computed.usercomment: exif test image.
computed.usercommentencoding: ascii
computed.copyright: photo (c) m.boerger, edited by m.boerger.
computed.copyright.photographer: photo (c) m.boerger
computed.copyright.editor: edited by m.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
//*/
$index="1"; //定義索引
$string=exif_tagname($index); //獲得圖像索引的頭信息
echo $string; //輸出結果
//
if(array_key_exists('file',$_request))
{
$image=exif_thumbnail($_request['file'],$width,$height,$type); //取得文件的縮略圖
}
else //如果數組不存在相應的鍵值
{
$image=false; //返回錯誤
}
if($image!==false) //如果返回true
{
header("content-type:".image_type_to_mime_type($type)); //發送頭文件
echo $image; //輸出縮略圖
exit; //結束php教程代碼
}
else //如果返回錯誤
{
echo "no thumbnail available"; //輸出信息
}