Merge pull request #184 from andrew-kzoo/fix-exif-imagetype

Get image dimensions without EXIF extension
This commit is contained in:
Ivan Lanin 2014-03-28 09:56:37 +07:00
commit de286936f2
2 changed files with 12 additions and 2 deletions

View File

@ -116,7 +116,12 @@ class Image
throw new InvalidImageException;
}
$imgData = getimagesize($source);
$this->imageType = exif_imagetype($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

@ -254,7 +254,12 @@ class Word2007 implements IWriter
if (stripos(strrev($src), strrev('.php')) === 0) {
$extension = 'php';
} else {
$imageType = exif_imagetype($src);
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) {