<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Retrieve the embedded thumbnail of a TIFF or JPEG image</title> </head> <body><div class="manualnavbar" 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" id="refsect1-function.exif-thumbnail-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>exif_thumbnail</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$width</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$height</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$imagetype</code></span> ]]] )</div> <p class="para rdfs-comment"> <span class="function"><strong>exif_thumbnail()</strong></span> 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 <span class="function"><a href="function.header.html" class="function">header()</a></span> function. </p> <p class="para"> It is possible that <span class="function"><strong>exif_thumbnail()</strong></span> cannot create an image but can determine its size. In this case, the return value is <strong><code>FALSE</code></strong> but <em><code class="parameter">width</code></em> and <em><code class="parameter">height</code></em> are set. </p> </div> <div class="refsect1 parameters" id="refsect1-function.exif-thumbnail-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">filename</code></em></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"><em><code class="parameter">width</code></em></span> <dd> <p class="para"> The return width of the returned thumbnail. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">height</code></em></span> <dd> <p class="para"> The returned height of the returned thumbnail. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">imagetype</code></em></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" id="refsect1-function.exif-thumbnail-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the embedded thumbnail, or <strong><code>FALSE</code></strong> if the image contains no thumbnail. </p> </div> <div class="refsect1 changelog" id="refsect1-function.exif-thumbnail-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>4.3.0</td> <td> The optional parameters <em><code class="parameter">width</code></em>, <em><code class="parameter">height</code></em>, and <em><code class="parameter">imagetype</code></em> all became available. </td> </tr> <tr> <td>4.3.0</td> <td> May return thumbnails in the <acronym title="Tagged Image File Format">TIFF</acronym> format. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.exif-thumbnail-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3165"> <p><strong>Example #1 <span class="function"><strong>exif_thumbnail()</strong></span> example</strong></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" id="refsect1-function.exif-thumbnail-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.exif-read-data.html" class="function" rel="rdfs-seeAlso">exif_read_data()</a> - Reads the EXIF headers from JPEG or TIFF</span></li> <li class="member"> <span class="function"><a href="function.image-type-to-mime-type.html" class="function" rel="rdfs-seeAlso">image_type_to_mime_type()</a> - Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" 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>