Commit a7d5e2fd authored by Richard Mansfield's avatar Richard Mansfield

Check mimetype when bits per pixel not returned by gd (bug #784978)

Sometimes when creating a thumbnail image, getimagesize doesn't return
a value for bits per pixel on certain gifs.  This creates warnings in
the logs when approximating the required memory consumption, and also
refuses to create the thumbnail.  We can check the mimetype of the
image when 'bits' is not set, and when it's a gif, just assume the
maximum value (8 bpp).

Change-Id: Ie4a7161f8e17fa17291448084a57fa13873e0e4a
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a2f57d5e
......@@ -527,8 +527,14 @@ function get_dataroot_image_path($path, $id, $size=null) {
// gd can eat a lot of memory shrinking large images, so use a placeholder image
// here if necessary
if (isset($imageinfo[0]) && isset($imageinfo[1]) && isset($imageinfo['bits'])) {
$approxmem = $imageinfo[0] * $imageinfo[1] * ($imageinfo['bits'] / 8)
if (isset($imageinfo['bits'])) {
$bits = $imageinfo['bits'];
}
else if ($imageinfo['mime'] == 'image/gif') {
$bits = 8;
}
if (isset($imageinfo[0]) && isset($imageinfo[1]) && !empty($bits)) {
$approxmem = $imageinfo[0] * $imageinfo[1] * ($bits / 8)
* (isset($imageinfo['channels']) ? $imageinfo['channels'] : 3);
}
if (empty($approxmem) || $approxmem > get_config('maximageresizememory')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment