File indexing completed on 2025-01-26 05:29:13

0001 <?php
0002 
0003 namespace Intervention\Image\Commands;
0004 
0005 class ExifCommand extends AbstractCommand
0006 {
0007     /**
0008      * Read Exif data from the given image
0009      *
0010      * Note: Windows PHP Users - in order to use this method you will need to
0011      * enable the mbstring and exif extensions within the php.ini file.
0012      *
0013      * @param  \Intervention\Image\Image $image
0014      * @return boolean
0015      */
0016     public function execute($image)
0017     {
0018         if ( ! function_exists('exif_read_data')) {
0019             throw new \Intervention\Image\Exception\NotSupportedException(
0020                 "Reading Exif data is not supported by this PHP installation."
0021             );
0022         }
0023 
0024         $key = $this->argument(0)->value();
0025 
0026         // try to read exif data from image file
0027         $data = @exif_read_data($image->dirname .'/'. $image->basename);
0028 
0029         if (! is_null($key) && is_array($data)) {
0030             $data = array_key_exists($key, $data) ? $data[$key] : false;
0031         }
0032 
0033         $this->setOutput($data);
0034 
0035         return true;
0036     }
0037 }