Check whether data is parsable by 'imagecreatefromstring' in jimIcon.
This commit is contained in:
parent
42173386b3
commit
7c966b69d5
|
@ -104,12 +104,12 @@ class jimIcon {
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we can parse it (might be PNG format here)
|
// See if we can parse it (might be PNG format here)
|
||||||
$i = @imagecreatefromstring($data);
|
if (self::has_parsable_image_type($data)) {
|
||||||
|
if ($i = @imagecreatefromstring($data)) {
|
||||||
if ($i) {
|
|
||||||
imagesavealpha($i, true);
|
imagesavealpha($i, true);
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Must be a BMP. Parse it ourselves.
|
// Must be a BMP. Parse it ourselves.
|
||||||
$img = imagecreatetruecolor($e["width"], $e["height"]);
|
$img = imagecreatetruecolor($e["width"], $e["height"]);
|
||||||
|
@ -267,5 +267,12 @@ class jimIcon {
|
||||||
}
|
}
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks whether the data is a type parsable by imagecreatefromstring()
|
||||||
|
private function has_parsable_image_type($image_data) {
|
||||||
|
$size = getimagesizefromstring($image_data);
|
||||||
|
return $size && in_array($size[2],
|
||||||
|
[IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_BMP, IMAGETYPE_WBMP, IMAGETYPE_WEBP]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue