eZ Publish  [4.0]
ezexifimageanalyzer.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZEXIFImageAnalyzer class
00004 //
00005 // Created on: <03-Nov-2003 15:19:16 amos>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file ezexifimageanalyzer.php
00032 */
00033 
00034 /*!
00035   \class eZEXIFImageAnalyzer ezexifimageanalyzer.php
00036   \ingroup eZImageAnalyzer
00037   \brief Analyzes image formats which can contain EXIF information.
00038 
00039 */
00040 
00041 class eZEXIFImageAnalyzer
00042 {
00043     /*!
00044      Constructor
00045     */
00046     function eZEXIFImageAnalyzer()
00047     {
00048     }
00049 
00050     /*!
00051      \reimp
00052      Checks the file for EXIF data and returns the information.
00053     */
00054     function process( $mimeData, $parameters = array() )
00055     {
00056         $printInfo = false;
00057         if ( isset( $parameters['print_info'] ) )
00058             $printInfo = $parameters['print_info'];
00059 
00060         $filename = $mimeData['url'];
00061         if ( file_exists( $filename ) )
00062         {
00063             if ( function_exists( 'exif_read_data' ) )
00064             {
00065                 $exifData = exif_read_data( $filename, "COMPUTED,IFD0,COMMENT,EXIF", true );
00066                 if ( $exifData )
00067                 {
00068                     $info = array();
00069                     if ( isset( $exifData['COMPUTED'] ) )
00070                     {
00071                         foreach ( $exifData['COMPUTED'] as $key => $item )
00072                         {
00073                             if ( strtolower( $key ) == 'html' )
00074                                 continue;
00075                             $info[$key] = $exifData['COMPUTED'][$key];
00076                         }
00077                     }
00078                     if ( isset( $exifData['IFD0'] ) )
00079                     {
00080                         $info['ifd0'] = $exifData['IFD0'];
00081                     }
00082                     if ( isset( $exifData['EXIF'] ) )
00083                     {
00084                         $info['exif'] = $exifData['EXIF'];
00085                     }
00086                     return $info;
00087                 }
00088             }
00089         }
00090         return false;
00091     }
00092 
00093 }
00094 
00095 ?>