Exif.php 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @package Grav\Common\Helpers
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Helpers;
  9. use Grav\Common\Grav;
  10. class Exif
  11. {
  12. public $reader;
  13. /**
  14. * Exif constructor.
  15. * @throws \RuntimeException
  16. */
  17. public function __construct()
  18. {
  19. if (Grav::instance()['config']->get('system.media.auto_metadata_exif')) {
  20. if (function_exists('exif_read_data') && class_exists('\PHPExif\Reader\Reader')) {
  21. $this->reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);
  22. } else {
  23. throw new \RuntimeException('Please enable the Exif extension for PHP or disable Exif support in Grav system configuration');
  24. }
  25. }
  26. }
  27. public function getReader()
  28. {
  29. if ($this->reader) {
  30. return $this->reader;
  31. }
  32. return false;
  33. }
  34. }