-
-
Save salathe/8317870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@inheritdoc} | |
* | |
* @note Image dimensions returned as array(width, height) | |
*/ | |
public function fetchMetaDataFrom($filePath) | |
{ | |
if (!file_exists($filePath)) | |
throw new MetaDataFileNotFoundException(sprintf("File %s could not be found for metadata retrieval", $filePath)); | |
$metadata = @getimagesize($filePath); | |
if ($metadata === false) | |
throw new MetaDataFileNotReadableException(sprintf("File %s metadata couldn't be read. Permissions problem?", $filePath)); | |
list($width, $height, $type, /** Skip $attr **/) = $metadata; | |
$extension = $this->resolveImageType($type); | |
if (!in_array($extension, $this->allowedImageTypes)) | |
throw new MetaDataImageExtensionNotAllowedException(sprintf("File %s wasn't in allowed image types: %s", $extension, print_r($this->allowedImageTypes, true))); | |
return array($width, $height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment