Skip to content

Commit 2783e2f

Browse files
author
Mitch
committed
Ensure loadFromString() throws an exception for unsupported image types
1 parent 6cadf1f commit 2783e2f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ImageResize.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@ public function loadFromString($imagedata)
9898
$this->source_type
9999
) = $image_info;
100100

101-
$this->source_image = imagecreatefromstring($imagedata);
101+
switch ($this->source_type) {
102+
case IMAGETYPE_GIF:
103+
case IMAGETYPE_JPEG:
104+
case IMAGETYPE_PNG:
105+
$this->source_image = imagecreatefromstring($imagedata);
106+
break;
107+
108+
default:
109+
throw new \Exception('Unsupported image type');
110+
break;
111+
}
102112

103113
return $this->resize($this->getSourceWidth(), $this->getSourceHeight());
104114
}

0 commit comments

Comments
 (0)