From 3b5404725380d586627678ab1637a7c224b1ba77 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 5 Feb 2014 09:43:10 -0800 Subject: [PATCH] Preference added for thumbnail quality generated by thumb.php. Can have a dramatic effect on page-load times/performance. --- e107_admin/image.php | 2 ++ e107_core/xml/default_install.xml | 1 + thumb.php | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 88887ce97..c83a4d66a 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -696,6 +696,8 @@ class media_admin_ui extends e_admin_ui 'image_post_class' => array('title'=> IMALAN_10, 'type' => 'userclass', 'data'=>'int', 'writeParms'=>'help=IMALAN_11&classlist=public,guest,nobody,member,admin,main,classes' ), 'image_post_disabled_method' => array('title'=> IMALAN_12, 'type' => 'boolean','writeParms'=>'enabled=IMALAN_15&disabled=IMALAN_14'), 'resize_method' => array('title'=> IMALAN_3, 'type'=>'method', 'data'=>'str'), + 'thumbnail_quality' => array('title'=> "Thumbnail Quality", 'type'=>'number', 'data'=>'int', 'writeParms'=>'help=Set this as low as possible before quality loss is apparent. Max. 100'), //TODO LAN + 'im_width' => array('title'=> "Avatar Width", 'type'=>'number', 'data'=>'int', 'writeParms'=>'help=Avatar images will be constrained to these dimensions (in pixels)'), //TODO LAN 'im_height' => array('title'=> "Avatar Height", 'type'=>'number', 'data'=>'int', 'writeParms'=>'help=Avatar images will be constrained to these dimensions (in pixels)'), 'resize_dimensions' => array('title'=> "Resize-Image Dimensions", 'type'=>'method', 'data'=>'str'), diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml index d5e551660..119e1f597 100644 --- a/e107_core/xml/default_install.xml +++ b/e107_core/xml/default_install.xml @@ -245,6 +245,7 @@ City, State, Country 0 canvas.css + 75 0 GMT 1 diff --git a/thumb.php b/thumb.php index 7ac04d9d3..e5c44e0b5 100644 --- a/thumb.php +++ b/thumb.php @@ -70,6 +70,8 @@ class e_thumbpage protected $_watermark = array(); private $_placeholder = false; + + protected $_thumbQuality = null; /** * Constructor - init paths @@ -142,6 +144,9 @@ class e_thumbpage 'shadowcolor' => vartrue($pref['watermark_shadowcolor'], '000000'), 'opacity' => vartrue($pref['watermark_opacity'], 20) ); + + $this->_thumbQuality = vartrue($pref['thumbnail_quality'],65); + // parse request $this->parseRequest(); @@ -231,7 +236,7 @@ class e_thumbpage $thumbnfo = pathinfo($this->_src_path); $options = $this->getRequestOptions(); - $cache_str = md5(serialize($options).$this->_src_path); + $cache_str = md5(serialize($options). $this->_src_path. $this->_thumbQuality); $fname = strtolower('Thumb_'.$thumbnfo['filename'].'_'.$cache_str.'.'.$thumbnfo['extension']).'.cache.bin'; @@ -269,7 +274,7 @@ class e_thumbpage { $thumb = PhpThumbFactory::create($this->_src_path); $sizeUp = ($this->_request['w'] > 110) ? true : false; // don't resizeUp the icon images. - $thumb->setOptions(array('correctPermissions' => true, 'resizeUp'=>$sizeUp)); + $thumb->setOptions(array('correctPermissions' => true, 'resizeUp' => $sizeUp, 'jpegQuality' => $this->_thumbQuality)); } catch (Exception $e)