From 22f4320bdb7d039e3ed818cf9b735301ce72f9ab Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 13 Jun 2002 11:18:52 +0000 Subject: [PATCH] Changes to support GD 1 and GD 2. Well, to be more accurate, we now rely on the administrator to tell us which is installed because PHP is not reliable (eg GD 2.* functions are available in 4.0.6 and later EVEN WHEN gd 2 is not present ... sigh). So, new config variable $CFG->gdversion --- config-dist.php | 6 ++++++ user/edit.php | 2 +- user/lib.php | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config-dist.php b/config-dist.php index 638f9704df..035806c360 100644 --- a/config-dist.php +++ b/config-dist.php @@ -71,6 +71,12 @@ $CFG->lang = "en"; $CFG->smtphosts = ""; +// There is no way, currently, to automatically tell whether the graphic +// library GD is version 1.* or 2.*. Specify that here (either 1 or 2). + +$CFG->gdversion = 1; + + // You should not need to change anything else. To continue setting up // Moodle, use your web browser to go to the moodle/admin web page. /////////////////////////////////////////////////////////////////////////// diff --git a/user/edit.php b/user/edit.php index 36db01e35f..9e06031e2e 100644 --- a/user/edit.php +++ b/user/edit.php @@ -47,7 +47,7 @@ case 3: $im = ImageCreateFromPNG($imagefile); break; default: error("Image must be in JPG or PNG format"); } - if (function_exists("ImageCreateTrueColor")) { + if (function_exists("ImageCreateTrueColor") and $CFG->gdversion >= 2) { $im1 = ImageCreateTrueColor(100,100); $im2 = ImageCreateTrueColor(35,35); } else { diff --git a/user/lib.php b/user/lib.php index b9dce9eb40..07eafa7cba 100644 --- a/user/lib.php +++ b/user/lib.php @@ -4,7 +4,9 @@ function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { - if (function_exists("ImageCopyResampled")) { // Assumes gd >= 2.0.1 as well + global $CFG; + + if (function_exists("ImageCopyResampled") and $CFG->gdversion >= 2) { return ImageCopyResampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); } -- 2.39.5