[ansel] Patch for user pref image type

Heath S. Hendrickson heath at outerspaceconsultants.com
Tue Jan 20 13:08:22 PST 2004


Seeing wisdom in Ben's comment (and Chuck's agreement), attached is a 
patch that will allow the system admin to configure the file type for 
created images.  It's a patch against config/conf.xml and 
lib/Ansel.php.  I've removed it from the pref area as it was never 
really intended for per-user configuration (it was just the first place 
I thought to put it).

heath

Chuck Hagenbuch wrote:

>Quoting "Heath S. Hendrickson" <heath at outerspaceconsultants.com>:
>
>  
>
>>As it's set up now, the only choices listed are both available in IM and
>>GD.
>>    
>>
>
>... *IF*, and ONLY if, you've compiled it in. That's far from guaranteed.
>
>Also, the fact that ansel works currently makes your argument about needing JPEG
>support bull.
>
>I agree with Ben that a conf option makes sense, but definitely not a
>preference.
>
>-chuck
>
>--
>Charles Hagenbuch, <chuck at horde.org>
>"Here, I brought some cole slaw. It's made from peeeooople! Just kidding."
>
>  
>

-------------- next part --------------
Index: config/conf.xml
===================================================================
RCS file: /usr/local/horde/cvs/ansel/config/conf.xml,v
retrieving revision 1.11
diff -u -r1.11 conf.xml
--- config/conf.xml	7 Jan 2004 22:44:58 -0000	1.11
+++ config/conf.xml	20 Jan 2004 20:59:48 -0000
@@ -45,4 +45,15 @@
   <configstring name="height_max" desc="Maximum allowed screen image height">768</configstring>
  </configsection>
 
+ <configsection name="im_type" desc="File Format Setting">
+  <configheader>File Format Setting</configheader>
+  <configenum name="format" desc="What format should system created images be stored in (JPEG or PNG).">
+     PNG 
+     <values>
+       <value>PNG</value>
+       <value>JPEG</value>
+     </values>
+  </configenum>
+ </configsection>
+
 </configuration>
Index: lib/Ansel.php
===================================================================
RCS file: /usr/local/horde/cvs/ansel/lib/Ansel.php,v
retrieving revision 1.37
diff -u -r1.37 Ansel.php
--- lib/Ansel.php	19 Jan 2004 18:22:50 -0000	1.37
+++ lib/Ansel.php	20 Jan 2004 21:05:29 -0000
@@ -142,10 +142,16 @@
     {
         global $conf;
         require_once HORDE_LIBS . 'Horde/Image.php';
+        // sets the image type based on conf.php, defaults to 'png'
+        if(!empty($conf['im_type']['format'])) {
+            $im_type = strtolower($conf['im_type']['format']);
+        } else {
+            $im_type = 'png';
+        }
         if (!empty($conf['image']['convert'])) {
-            return Horde_Image::singleton('im');
+            return Horde_Image::singleton('im',array( 'type' => $im_type ));
         } else {
-            return Horde_Image::singleton('gd');
+            return Horde_Image::singleton('gd',array( 'type' => $im_type ));
         }
     }
 


More information about the ansel mailing list