From 5f87220ddab78987cdd53abd5f31a9b4d3b6aeaa Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Tue, 26 Dec 2006 14:01:41 +0000
Subject: [PATCH] - Patch #105164 by kkaefer: image quality settings toggle.

---
 UPGRADE.txt                  | 72 ++++++++++++++++++++++++++++++++----
 includes/image.inc           | 24 ++++++++++--
 modules/system/system.module |  8 ++--
 3 files changed, 89 insertions(+), 15 deletions(-)

diff --git a/UPGRADE.txt b/UPGRADE.txt
index c9b525951138..8ed1be1ebd56 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -5,15 +5,73 @@ UPGRADING
 
 1. Backup your database and Drupal directory - especially your
    sites-directory which contains your configuration file and
-   any added modules and themes.
+   added modules and themes, any contributed modules
+   in your modules-directory, and your files-directory which
+   contains uploaded files.
 
-2. Log on as the user with user ID 1.
+   Note:  For a single site setup the configuration file is the
+   "settings.php" file located at sites/default/settings.php.
+   For multisite configuration the configuration file is
+   located in a structure like the following:
+    sites/default/settings.php
+    sites/example.com/settings.php
+    sites/sub.example.com/settings.php
+    sites/sub.example.com.site3/settings.php
+   More information on multisite configuration is located in
+   the INSTALL.txt file.
 
-3. Remove all the old Drupal files then unpack the new Drupal
-   files into the directory that you run Drupal from.
+2. Disable contributed modules and switch to a core theme
+   (bluemarine or garland).
 
-4. Modify the new configuration file to make sure
-   it has the latest and correct information.
+3. Log on as the user with user ID 1.  (User ID 1 is the first
+   account created and the main administrator account.)  User
+   ID 1 needs to be logged in so that you can access update.php
+   file (step 8) which can only be run by user ID 1.  Do not
+   close your browser until step 9 is complete.
 
-5. Run update.php by visiting http://www.example.com/update.php.
+4. Remove all of the old files and directories from the
+   Drupal installation directory.
 
+5. Unpack the new Drupal files and directories into the Drupal
+   installation directory.
+
+6. Copy the backed up files-directory and sites-directories to the
+   Drupal installation directory. If the original .htaccess or
+   robots.txt files have been modified, copy the backed up
+   versions of these files to the installation directory
+   directory as well.
+
+7. Verify the new configuration file to make sure it has the
+   latest and correct information.
+
+8. (Optional) Re-install contributed modules.
+
+   Note:  Make sure the version of a module matches your
+   version of Drupal.  Modules from previous versions may
+   not be compatible with the current version.  Check
+   http://drupal.org/project/Modules for the version of a
+   module to match your version of Drupal.
+
+9. Run update.php by visiting http://www.example.com/update.php
+   (replace www.example.com with your drupal installations domain
+   name).  This step will update the database to the new Drupal
+   installation.
+
+   Note: If you are unable to access update.php as user ID 1
+   do the following:
+
+   - With a text editor find the update.php file on your system.
+   It should be in the main Drupal directory that you installed
+   all the files into.
+
+   - There is a line near top of update.php that says
+   $access_check = TRUE;. Change it to $access_check = FALSE;.
+
+   - As soon as the script is done, you must change the update.php
+   script back to its original form to $access_check = TRUE;.
+
+Note: Upgrading sequentially is recommended, one release at a time.
+It is possible to skip releases, but is not advised.
+
+For more information on upgrading visit the Drupal handbook at
+http://drupal.org/upgrade
\ No newline at end of file
diff --git a/includes/image.inc b/includes/image.inc
index fb3689d71431..5013d09a3f3e 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -177,11 +177,24 @@ function image_crop($source, $destination, $x, $y, $width, $height) {
  */
 
 /**
- * Retrieve settings for the GD2 toolkit (not used).
+ * Retrieve settings for the GD2 toolkit.
  */
 function image_gd_settings() {
   if (image_gd_check_settings()) {
-    return t('The built-in GD2 toolkit is installed and working properly.');
+    $form = array();
+    $form['status'] = array('#value' => t('The built-in GD2 toolkit is installed and working properly.'));
+
+    $form['image_jpeg_quality'] = array(
+      '#type' => 'textfield',
+      '#title' => t('JPEG quality'),
+      '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
+      '#size' => 10,
+      '#maxlength' => 3,
+      '#default_value' => variable_get('image_jpeg_quality', 75),
+      '#field_suffix' => t('%'),
+    );
+
+    return $form;
   }
   else {
     form_set_error('image_toolkit', t('The built-in GD image toolkit requires that the GD module for PHP be installed and configured properly. For more information see <a href="@url">PHP\'s image documentation</a>.', array('@url' => 'http://php.net/image')));
@@ -304,7 +317,12 @@ function image_gd_close($res, $destination, $extension) {
   if (!function_exists($close_func)) {
     return FALSE;
   }
-  return $close_func($res, $destination);
+  if ($extension == 'jpeg') {
+    return $close_func($res, $destination, variable_get('image_jpeg_quality', 75));
+  }
+  else {
+    return $close_func($res, $destination);
+  }
 }
 
 
diff --git a/modules/system/system.module b/modules/system/system.module
index 27e406934581..b80f14262093 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -741,14 +741,12 @@ function system_image_toolkit_settings() {
       '#default_value' => variable_get('image_toolkit', image_get_toolkit()),
       '#options' => $toolkits_available
     );
-    $form['image_toolkit_settings'] = image_toolkit_invoke('settings');
-
-    return system_settings_form($form);
   }
   else {
-    $form['error'] = array('#value' => '<p>'. t("No image toolkits found.  Drupal will use PHP's built-in GD library for image handling.") .'</p>');
-    return $form;
+    $form['image_toolkit'] = array('#value' => '<p>'. t("No image toolkits found. Drupal will use PHP's built-in GD library for image handling.") .'</p>');
   }
+  $form['image_toolkit_settings'] = image_toolkit_invoke('settings');
+  return system_settings_form($form);
 }
 
 function system_rss_feeds_settings() {
-- 
GitLab