Int exif_imagetype (string $ filename)
1 imagetype_gif
2 imagetype_jpeg
3 imagetype_png
4 imagetype_swf
5 imagetype_ps tutorial d
6 imagetype_bmp
7 imagetype_0000_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"; // definition file
If (exif_imagetype ($ img )! = Imagetype_gif) // you can specify the file type.
{
Echo "the specified image is not a GIF image"; // output result
}
Else
{
Echo "the specified image is a GIF image ";
}
/*
Array exif_read_data (string $ filename [, string $ sections = null [, bool $ arrays = false [, bool $ thumbnail = false])
*/
Echo "test1.jpg: <br/> n"; // output file name
$ Exif = exif_read_data ('tests/test1.jpg ', 'ifd0'); // Read File 1 Information
// Judge based on the result
Echo $ exif = false? "No header data found. <br/> n": "image contains headers <br/> n ";
$ Exif = exif_read_data ('tests/test2.jpg ', 0, true); // Read File 2 Information
Echo "test2.jpg: <br/> n"; // output file name
Foreach ($ exif as $ key => $ section) // read information cyclically
{
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.jpeg interchangeformat: 134
Thumbnail.jpeg interchangeformatsize: 523
Comment.0: comment #1.
Comment.1: comment #2.
Comment.2: comment # 3end
Thumbnail.jpeg interchangeformat: 134
Thumbnail. thumbnail. height: 1
Thumbnail. thumbnail. height: 1
//*/
$ Index = "1"; // define an index
$ String = exif_tagname ($ index); // obtain the header information of the image index.
Echo $ string; // output result
//
If (array_key_exists ('file', $ _ request ))
{
$ Image = exif_thumbnail ($ _ request ['file'], $ width, $ height, $ type); // retrieves a thumbnail of a file
}
Else // If the array does not have the corresponding key value
{
$ Image = false; // an error is returned.
}
If ($ image! = False) // if true is returned
{
Header ("content-type:". image_type_to_mime_type ($ type); // send the header file
Echo $ image; // outputs a thumbnail.
Exit; // end the php tutorial code
}
Else // if an error is returned
{
Echo "no thumbnail available"; // output information
}