[limb-svn] r5840 - 3.x/trunk/limb/imagekit/src

svn at limb-project.com svn at limb-project.com
Tue May 8 20:33:55 MSD 2007


Author: pachanga
Date: 2007-05-08 20:33:55 +0400 (Tue, 08 May 2007)
New Revision: 5840
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5840

Modified:
   3.x/trunk/limb/imagekit/src/lmbImageLibrary.class.php
Log:
-- better error messages

Modified: 3.x/trunk/limb/imagekit/src/lmbImageLibrary.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/lmbImageLibrary.class.php	2007-05-08 16:17:44 UTC (rev 5839)
+++ 3.x/trunk/limb/imagekit/src/lmbImageLibrary.class.php	2007-05-08 16:33:55 UTC (rev 5840)
@@ -1,13 +1,13 @@
 <?php
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright  Copyright &copy; 2004-2007 BIT
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- * @version    $Id$
- * @package    imagekit
+/**
+ * Limb Web Application Framework
+ *
+ * @link http://limb-project.com
+ *
+ * @copyright  Copyright &copy; 2004-2007 BIT
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ * @version    $Id$
+ * @package    imagekit
  */
 define('LIMB_IMAGE_LIBRARY_FLIP_HORIZONTAL', 1);
 define('LIMB_IMAGE_LIBRARY_FLIP_VERTICAL', 2);
@@ -36,8 +36,8 @@
 
   function setInputType($type)
   {
-    if (!$this->isTypeReadSupported($type))
-      throw new lmbException('type not supported');
+    if(!$this->isTypeReadSupported($type))
+      throw new lmbException("Type '$type' not supported");
 
     $this->input_file_type = $type;
   }
@@ -51,53 +51,53 @@
 
   function setOutputType($type)
   {
-    if (!$this->isTypeCreateSupported($type))
-      throw new lmbException('type not supported');
+    if(!$this->isTypeCreateSupported($type))
+      throw new lmbException("Type '$type' not supported");
 
     $this->output_file_type = $type;
   }
 
   function fallBackToAnySupportedType($type)
   {
-    if ($this->isTypeCreateSupported($type))
+    if($this->isTypeCreateSupported($type))
       return $type;
 
-    if ($this->isTypeCreateSupported('PNG'))
+    if($this->isTypeCreateSupported('PNG'))
       return 'PNG';
 
-    if ($this->isTypeCreateSupported('JPEG'))
+    if($this->isTypeCreateSupported('JPEG'))
       return 'JPEG';
 
-    throw new lmbException('no file type supported');
+    throw new lmbException("File type '$type' not supported");
   }
 
   function getImageType($str)
   {
-    if (preg_match("/bmp/i", $str))
+    if(preg_match("/bmp/i", $str))
       return 'BMP';
 
-    if (preg_match("/gif/i", $str))
+    if(preg_match("/gif/i", $str))
       return 'GIF';
 
-    if (preg_match("/png/i", $str))
+    if(preg_match("/png/i", $str))
       return 'PNG';
 
-    if (preg_match("/(jpeg|jpg)/i", $str))
+    if(preg_match("/(jpeg|jpg)/i", $str))
       return 'JPEG';
   }
 
   function getMimeType($str)
   {
-    if (preg_match("/bmp/i", $str))
+    if(preg_match("/bmp/i", $str))
       return 'image/bmp';
 
-    if (preg_match("/gif/i", $str))
+    if(preg_match("/gif/i", $str))
       return 'image/gif';
 
-    if (preg_match("/png/i", $str))
+    if(preg_match("/png/i", $str))
       return 'image/png';
 
-    if (preg_match("/(jpeg|jpg)/i", $str))
+    if(preg_match("/(jpeg|jpg)/i", $str))
       return 'image/jpeg';
   }
 
@@ -123,23 +123,23 @@
 
   function getDstDimensions($src_width, $src_height, $params)
   {
-    if (isset($params['max_dimension']))
+    if(isset($params['max_dimension']))
     {
       $params['preserve_aspect_ratio'] = true;
-      if ($src_width > $src_height)
+      if($src_width > $src_height)
         $params['width'] = $params['max_dimension'];
       else
         $params['height'] = $params['max_dimension'];
     }
 
-    if (isset($params['scale_factor']))
+    if(isset($params['scale_factor']))
     {
       $dst_width = floor($src_width * $params['scale_factor']);
       $dst_height = floor($src_height * $params['scale_factor']);
     }
     elseif(isset($params['xscale']) ||  isset($params['yscale']))
     {
-      if (isset($params['xscale']))
+      if(isset($params['xscale']))
         $dst_width = floor($src_width * $params['xscale']);
       else
         if(isset($params['preserve_aspect_ratio']))
@@ -147,7 +147,7 @@
         else
           $dst_width = $src_width;
 
-      if (isset($params['yscale']))
+      if(isset($params['yscale']))
         $dst_height = floor($src_height * $params['yscale']);
       else
         if(isset($params['preserve_aspect_ratio']))
@@ -157,7 +157,7 @@
     }
     elseif(isset($params['width']) ||  isset($params['height']))
     {
-      if (isset($params['width']))
+      if(isset($params['width']))
         $dst_width = $params['width'];
       else
         if(isset($params['preserve_aspect_ratio']))
@@ -168,7 +168,7 @@
         else
           $dst_width = $src_width;
 
-      if (isset($params['height']))
+      if(isset($params['height']))
         $dst_height = $params['height'];
       else
         if(isset($params['preserve_aspect_ratio']))



More information about the limb-svn mailing list