NYCPHP Meetup

NYPHP.org

[nycphp-talk] has anyone ever used "exif_thumbnail()" PHP 4.3+?

Phillip Powell phillip.powell at adnet-sys.com
Wed May 5 16:17:48 EDT 2004


PHP 4.3.2 with --enable-exif

I have the following class:

[CODE]
<?php

class ThumbGenerator extends MethodGeneratorForActionPerformer {
 
  function ThumbGenerator() {      // CONSTRUCTOR
    // DO ALL KINDS OF STUFF HERE
  }

  /**
   * This method can only be used if you are using PHP version 4.3+ and 
if you have TIFF or JPEG image
   *
   * @access private
   */
  function generateTIFFJPEGThumb() {                            // VOID 
METHOD
        global $section, $thumbLocationPath;
        
/*------------------------------------------------------------------------------------------------------------------------------------------
            Because of the different methodologies of each method, the 
constructor must be called, thus, the class object
            must be initiated.  If "$this" does not exist, trigger an error
        
-------------------------------------------------------------------------------------------------------------------------------------------*/
        if (!$this || !is_object($this)) trigger_error('You must first 
instantiate a ThumbGenerator object to use this method', E_USER_ERROR);

        // STREAM FILE EMBEDDED THUMBNAIL CONTENTS INTO BINARY STRING 
VARIABLE
        if ($this->isSuccessful) {
         $thumbStreamObj = exif_thumbnail($this->locationPath . '/' . 
$this->fileName, $width, $height, $mimeTypeInt);
         print_r('<P>thumbStreamObj: '); print_r($thumbStreamObj);
         if (!$thumbStreamObj) {
          $this->isSuccessful = false;
          $this->setErrorArray(array('section' => 'Could not extract 
embedded thumbnail contents from "' . $this->locationPath . '/' . 
$this->fileName . '"'));
         }
        }

    }

}

?>
[/CODE]

The class is being used to literally generate a thumbnail from an 
existing image.  I read in the PHP manual (see 
http://us3.php.net/manual/en/function.exif-thumbnail.php ) that 
exif_thumbnail() only extracts embedded thumbnail information from a 
TIFF or JPEG
image.  In knowing that I've simplified my method to only handle TIFF or 
JPEG images (this is done in the class constructor - sorting out what 
image type you got).

At this point, however, I am receiving nothing into the $thumbStreamObj 
binary stream string variable; it's "empty" (false):

[CODE]$thumbstreamObj = exif_thumbnail($this->locationPath . '/' . 
$this->fileName, $width, $height, $mimeTypeInt);[/CODE]

I checked the values of $this->fileName and $this->locationPath and both 
contain the correct values to be able to locate the image in the system 
for the function to extract the embedded thumbnail information 
reportedly found in TIFF and JPEG images.

Has anyone had any luck using this to create a thumbnail?  I could use 
some more experted advice than I would think to find in the manual 
notes, which I am certain I'll find among you gurus here.

Thanx
Phil

-- 
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
ADNET Systems., Inc.
11260 Roger Bacon Drive Suite 403
Reston, VA  20191
#: (703) 709-7218 x107 
Fax: (703) 709-7219

	




More information about the talk mailing list