File indexing completed on 2025-01-26 05:29:14
0001 <?php 0002 0003 namespace Intervention\Image\Imagick\Commands; 0004 0005 use Intervention\Image\Commands\ExifCommand as BaseCommand; 0006 0007 class ExifCommand extends BaseCommand 0008 { 0009 /** 0010 * Prefer extension or not 0011 * 0012 * @var bool 0013 */ 0014 private $preferExtension = true; 0015 0016 /** 0017 * 0018 */ 0019 public function dontPreferExtension() { 0020 $this->preferExtension = false; 0021 } 0022 0023 /** 0024 * Read Exif data from the given image 0025 * 0026 * @param \Intervention\Image\Image $image 0027 * @return boolean 0028 */ 0029 public function execute($image) 0030 { 0031 if ($this->preferExtension && function_exists('exif_read_data')) { 0032 return parent::execute($image); 0033 } 0034 0035 $core = $image->getCore(); 0036 0037 if ( ! method_exists($core, 'getImageProperties')) { 0038 throw new \Intervention\Image\Exception\NotSupportedException( 0039 "Reading Exif data is not supported by this PHP installation." 0040 ); 0041 } 0042 0043 $requestedKey = $this->argument(0)->value(); 0044 if ($requestedKey !== null) { 0045 $this->setOutput($core->getImageProperty('exif:' . $requestedKey)); 0046 return true; 0047 } 0048 0049 $exif = []; 0050 $properties = $core->getImageProperties(); 0051 foreach ($properties as $key => $value) { 0052 if (substr($key, 0, 5) !== 'exif:') { 0053 continue; 0054 } 0055 0056 $exif[substr($key, 5)] = $value; 0057 } 0058 0059 $this->setOutput($exif); 0060 return true; 0061 } 0062 }