[pLog-svn] r2622 - plog/branches/plog-1.0.2/class/gallery/resizers

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Thu Nov 24 05:25:19 GMT 2005


Author: jondaley
Date: 2005-11-24 05:25:19 +0000 (Thu, 24 Nov 2005)
New Revision: 2622

Modified:
   plog/branches/plog-1.0.2/class/gallery/resizers/gallerygdresizer.class.php
Log:
apply priii's patch for correct thumbnail sizing.  http://bugs.lifetype.net/view.php?id=717  This patch should probably either be also applied to the imagemagick code, or else put in a common place.  see notes in mantis

Modified: plog/branches/plog-1.0.2/class/gallery/resizers/gallerygdresizer.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/gallery/resizers/gallerygdresizer.class.php	2005-11-24 05:23:28 UTC (rev 2621)
+++ plog/branches/plog-1.0.2/class/gallery/resizers/gallerygdresizer.class.php	2005-11-24 05:25:19 UTC (rev 2622)
@@ -48,9 +48,8 @@
 				$this->img["lebar_thumb"] = $this->img["lebar"];
 				$this->img["tinggi_thumb"] = $this->img["tinggi"];
 			}
-			else {
-				$this->size_height( $height );
-				$this->size_width( $width );
+            else {
+                $this->calcThumbFormat($width, $height);
 			}
 
             if( !$this->save( $outFile ))
@@ -78,9 +77,9 @@
             elseif ($this->img["format"]=="GIF") {
                 $this->img["format"]="GIF";
 				if( function_exists("imagecreatefromgif")) {
-                $this->img["src"] = @ImageCreateFromGIF ($imgfile);
+                    $this->img["src"] = @ImageCreateFromGIF ($imgfile);
 				}
-				else {
+                else {
 					return false;
 				}
 
@@ -319,5 +318,23 @@
 
             return $result;
         }
-	}
+
+        function calcThumbFormat($width, $height){
+            $ratioimg = (float) $this->img["lebar"] / (float) $this->img["tinggi"];
+            $ratiothumb=(float) $width / (float) $height;
+
+
+            if ($ratioimg == $ratiothumb){
+                $this->img["lebar_thumb"]=$width;
+                $this->img["tinggi_thumb"]=$height;
+            } elseif ($ratioimg > $ratiothumb){
+                $this->img["lebar_thumb"]=$width;
+                $this->img["tinggi_thumb"]=$width*((float)1/$ratioimg);
+            } elseif ($ratioimg < $ratiothumb){
+                $this->img["tinggi_thumb"]=$height;
+                $this->img["lebar_thumb"]=$height*$ratioimg;
+            }
+        }
+        
+    }
 ?>




More information about the pLog-svn mailing list