TYPO3 CMS  TYPO3_6-2
ImageInfo.php
Go to the documentation of this file.
1 <?php
3 
19 
23 class ImageInfo extends FileInfo {
24 
28  protected $imageSizes;
29 
35  public function getWidth() {
36  $imageSizes = $this->getImageSizes();
37  return $imageSizes[0];
38  }
39 
45  public function getHeight() {
46  $imageSizes = $this->getImageSizes();
47  return $imageSizes[1];
48  }
49 
53  protected function getImageSizes() {
54  if (is_null($this->imageSizes)) {
55  $this->imageSizes = getimagesize($this->getPathname());
56 
57  // Fallback to IM identify
58  if ($this->imageSizes === FALSE) {
59  $this->imageSizes = $this->getGraphicalFunctions()->imageMagickIdentify($this->getPathname());
60  }
61 
62  // In case the image size could not be retrieved, log the incident as a warning.
63  if (empty($this->imageSizes)) {
64  $this->getLogger()->warning('I could not retrieve the image size for file ' . $this->getPathname());
65  $this->imageSizes = array(0, 0);
66  }
67  }
68  return $this->imageSizes;
69  }
70 
74  protected function getLogger(){
76  $loggerManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\LogManager');
77 
78  return $loggerManager->getLogger(get_class($this));
79  }
80 
84  protected function getGraphicalFunctions() {
85  static $graphicalFunctions = NULL;
86 
87  if ($graphicalFunctions === NULL) {
88  $graphicalFunctions = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
89  }
90 
91  return $graphicalFunctions;
92  }
93 }