Get image dimensions without EXIF extension

Use `getimagesize` when `exif_imagetype` doesn't exist.
This commit is contained in:
Andrew Collins 2014-03-27 17:25:09 -04:00
parent c6fc1d4e89
commit a8da5b1b72
2 changed files with 12 additions and 2 deletions

View File

@ -132,7 +132,12 @@ class Image
throw new InvalidImageException;
}
$imgData = getimagesize($source);
if (function_exists('exif_imagetype')) {
$this->imageType = exif_imagetype($source);
} else {
$tmp = getimagesize($source);
$this->imageType = $tmp[2];
}
if (!in_array($this->imageType, $supportedTypes)) {
throw new UnsupportedImageTypeException;
}

View File

@ -270,7 +270,12 @@ class Word2007 implements IWriter
if (stripos(strrev($src), strrev('.php')) === 0) {
$extension = 'php';
} else {
if (function_exists('exif_imagetype')) {
$imageType = exif_imagetype($src);
} else {
$tmp = getimagesize($src);
$imageType = $tmp[2];
}
if ($imageType === \IMAGETYPE_JPEG) {
$extension = 'jpg';
} elseif ($imageType === \IMAGETYPE_GIF) {