📄 function.exif-thumbnail.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Retrieve the embedded thumbnail of a TIFF or JPEG image</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.exif-tagname.html">exif_tagname</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.read-exif-data.html">read_exif_data</a></div> <div class="up"><a href="ref.exif.html">Exif Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.exif-thumbnail" class="refentry"> <div class="refnamediv"> <h1 class="refname">exif_thumbnail</h1> <p class="verinfo">(PHP 4 >= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">exif_thumbnail</span> — <span class="dc-title">Retrieve the embedded thumbnail of a TIFF or JPEG image</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>exif_thumbnail</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&$width</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&$height</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&$imagetype</tt></span> ]]] )</div> <p class="para rdfs-comment"> <b>exif_thumbnail()</b> reads the embedded thumbnail of a <acronym title="Tagged Image File Format">TIFF</acronym> or <acronym title="Joint Photographic Experts Group">JPEG</acronym> image. </p> <p class="para"> If you want to deliver thumbnails through this function, you should send the mimetype information using the <a href="function.header.html" class="function">header()</a> function. </p> <p class="para"> It is possible that <b>exif_thumbnail()</b> cannot create an image but can determine its size. In this case, the return value is <b><tt>FALSE</tt></b> but <i><tt class="parameter">width</tt></i> and <i><tt class="parameter">height</tt></i> are set. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">filename</tt></i></span> <dd> <p class="para"> The name of the image file being read. This image contains an embedded thumbnail. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">width</tt></i></span> <dd> <p class="para"> The return width of the returned thumbnail. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">height</tt></i></span> <dd> <p class="para"> The returned height of the returned thumbnail. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">imagetype</tt></i></span> <dd> <p class="para"> The returned image type of the returned thumbnail. This is either <acronym title="Tagged Image File Format">TIFF</acronym> or <acronym title="Joint Photographic Experts Group">JPEG</acronym>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the embedded thumbnail, or <b><tt>FALSE</tt></b> if the image contains no thumbnail. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.3.0</td> <td colspan="1" rowspan="1" align="left"> The optional parameters <i><tt class="parameter">width</tt></i>, <i><tt class="parameter">height</tt></i>, and <i><tt class="parameter">imagetype</tt></i> all became available. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.3.0</td> <td colspan="1" rowspan="1" align="left"> May return thumbnails in the <acronym title="Tagged Image File Format">TIFF</acronym> format. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>exif_thumbnail()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">array_key_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'file'</span><span style="color: #007700">, </span><span style="color: #0000BB">$_REQUEST</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">$image </span><span style="color: #007700">= </span><span style="color: #0000BB">exif_thumbnail</span><span style="color: #007700">(</span><span style="color: #0000BB">$_REQUEST</span><span style="color: #007700">[</span><span style="color: #DD0000">'file'</span><span style="color: #007700">], </span><span style="color: #0000BB">$width</span><span style="color: #007700">, </span><span style="color: #0000BB">$height</span><span style="color: #007700">, </span><span style="color: #0000BB">$type</span><span style="color: #007700">);<br />} else {<br /> </span><span style="color: #0000BB">$image </span><span style="color: #007700">= </span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />}<br />if (</span><span style="color: #0000BB">$image</span><span style="color: #007700">!==</span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type: ' </span><span style="color: #007700">.</span><span style="color: #0000BB">image_type_to_mime_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$type</span><span style="color: #007700">));<br /> echo </span><span style="color: #0000BB">$image</span><span style="color: #007700">;<br /> exit;<br />} else {<br /> </span><span style="color: #FF8000">// no thumbnail available, handle the error here<br /> </span><span style="color: #007700">echo </span><span style="color: #DD0000">'No thumbnail available'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.exif-read-data.html" class="function" rel="rdfs-seeAlso">exif_read_data()</a></li> <li class="member"><a href="function.image-type-to-mime-type.html" class="function" rel="rdfs-seeAlso">image_type_to_mime_type()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.exif-tagname.html">exif_tagname</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.read-exif-data.html">read_exif_data</a></div> <div class="up"><a href="ref.exif.html">Exif Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -