Skip to content

Commit 5bc420b

Browse files
committed
Re-run getimagesize without source_info if false
Certain JPG images fail to get the $image_info variable when $this->source_info is set in the getimagesize function if the exif data is not what PHP is expecting. This ends up throwing exceptions instead of letting them through as though they do not have exif data. To allow valid images to make it through, we need to check to see if we can retreive $image_info via getimagesize WITH $this->source_info, if not (getimagesize returns FALSE), then get the $image_info without the $this->source_info. Then it will fall back to throwing the ImageResizeException if it still does not exist.
1 parent 0496393 commit 5bc420b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
vendor
3+
composer.lock

lib/ImageResize.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ public function __construct($filename)
7777
throw new ImageResizeException('Unsupported file type');
7878
}
7979

80-
$image_info = getimagesize($filename,$this->source_info);
80+
if (!$image_info = getimagesize($filename, $this->source_info)) {
81+
$image_info = getimagesize($filename);
82+
}
8183

8284
if (!$image_info) {
8385
throw new ImageResizeException('Could not read file');

0 commit comments

Comments
 (0)