Get image dimensions without EXIF extension
Use `getimagesize` when `exif_imagetype` doesn't exist.
This commit is contained in:
parent
c6fc1d4e89
commit
a8da5b1b72
|
|
@ -132,7 +132,12 @@ class Image
|
||||||
throw new InvalidImageException;
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
$imgData = getimagesize($source);
|
$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)) {
|
if (!in_array($this->imageType, $supportedTypes)) {
|
||||||
throw new UnsupportedImageTypeException;
|
throw new UnsupportedImageTypeException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,12 @@ class Word2007 implements IWriter
|
||||||
if (stripos(strrev($src), strrev('.php')) === 0) {
|
if (stripos(strrev($src), strrev('.php')) === 0) {
|
||||||
$extension = 'php';
|
$extension = 'php';
|
||||||
} else {
|
} 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) {
|
if ($imageType === \IMAGETYPE_JPEG) {
|
||||||
$extension = 'jpg';
|
$extension = 'jpg';
|
||||||
} elseif ($imageType === \IMAGETYPE_GIF) {
|
} elseif ($imageType === \IMAGETYPE_GIF) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue