Home > Backend Development > PHP Tutorial > Several simple picture judgment functions in php_PHP tutorial

Several simple picture judgment functions in php_PHP tutorial

WBOY
Release: 2016-07-13 10:45:53
Original
911 people have browsed it

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_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"; //Definition file
if(exif_imagetype($img)!=imagetype_gif) //Determine the file type
{
echo "The specified image is not a gif image"; //Output result
}
else
{
echo "The specified picture is a gif picture";
}

/*
array exif_read_data ( string $filename [, string $sections = null [, bool $arrays = false [, bool $thumbnail = false ]]] )

*/

echo "test1.jpg:
n"; //Output file name
$exif=exif_read_data('tests/test1.jpg','ifd0'); //Read file 1 information
                    //Judge based on the results
echo $exif===false ? "no header data found.
n":"image contains headers
n";
$exif=exif_read_data('tests/test2.jpg',0,true); //Read file 2 information
echo "test2.jpg:
n"; //Output file name
foreach($exif as $key=>$section) //Loop to read information
{
foreach($section as $name=>$val)
{
echo "$key.$name:$val
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"; //Define index
$string=exif_tagname($index); //Get 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); //Get the thumbnail of the file
}
else                       // If the array does not have the corresponding key value
{
$image=false; //Return error
}
if($image!==false) //If it returns true
{
header("content-type:".image_type_to_mime_type($type)); //Send header file
echo $image; //Output thumbnail
exit; //End php tutorial code
}
else                    //If an error is returned
{
echo "no thumbnail available"; //Output information
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632997.htmlTechArticleint geolocation_imagetype ( string $filename ) 1 imagetype_gif 2 imagetype_jpeg 3 imagetype_png 4 imagetype_swf 5 imagetype_ps 6 imagetype_bmp 7 imagetype_tiff_ii ( intel byte order...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template