[pLog-svn] r5992 - in plog/branches/lifetype-1.2: class/gallery/dao class/gallery/resizers templates/admin

reto at devel.lifetype.net reto at devel.lifetype.net
Sat Oct 20 10:29:55 EDT 2007


Author: reto
Date: 2007-10-20 10:29:55 -0400 (Sat, 20 Oct 2007)
New Revision: 5992

Modified:
   plog/branches/lifetype-1.2/class/gallery/dao/galleryresourcestorage.class.php
   plog/branches/lifetype-1.2/class/gallery/resizers/gallerygdresizer.class.php
   plog/branches/lifetype-1.2/templates/admin/globalsettings_resources.template
Log:
this should fix the wrong calculation of thumbnails when using GD. Plus I've put the config settings in the right order the be more consistent.
While fixing the bug I learned some malay - no, tinggi and lebar are no characters from a comic or something ;)

http://bugs.lifetype.net/view.php?id=1407



Modified: plog/branches/lifetype-1.2/class/gallery/dao/galleryresourcestorage.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/gallery/dao/galleryresourcestorage.class.php	2007-10-19 21:07:49 UTC (rev 5991)
+++ plog/branches/lifetype-1.2/class/gallery/dao/galleryresourcestorage.class.php	2007-10-20 14:29:55 UTC (rev 5992)
@@ -4,7 +4,7 @@
     lt_include( PLOG_CLASS_PATH."class/file/fileupload.class.php" );
     lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
     lt_include( PLOG_CLASS_PATH."class/file/fileuploads.class.php" );
-lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
     lt_include( PLOG_CLASS_PATH."class/gallery/galleryconstants.php" );
 
 	define( "RESOURCE_STORAGE_STORE_COPY", 1 );
@@ -317,7 +317,7 @@
 
 			$destFile = $destPath.$destFile;
 			if( $mode == RESOURCE_STORAGE_STORE_COPY )
-            		$res = File::copy( $fileName, $destFile );
+            	$res = File::copy( $fileName, $destFile );
 			else 
 				$res = File::rename( $fileName, $destFile );
             
@@ -455,5 +455,4 @@
 			return true;		
 		}
     }   
-?>      
-        
\ No newline at end of file
+?>

Modified: plog/branches/lifetype-1.2/class/gallery/resizers/gallerygdresizer.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/gallery/resizers/gallerygdresizer.class.php	2007-10-19 21:07:49 UTC (rev 5991)
+++ plog/branches/lifetype-1.2/class/gallery/resizers/gallerygdresizer.class.php	2007-10-20 14:29:55 UTC (rev 5992)
@@ -49,7 +49,7 @@
 				$this->img["tinggi_thumb"] = $this->img["tinggi"];
 			}
             else {
-                $this->calcThumbFormat($width, $height);
+                $this->calcThumbFormat($width, $height );
 			}
 
             if( !$this->save( $outFile ))
@@ -332,23 +332,27 @@
             return $result;
         }
 
-        function calcThumbFormat($width, $height){
-            $ratioimg = (float) $this->img["lebar"] / (float) $this->img["tinggi"];
-            $ratiothumb=(float) $width / (float) $height;
-
-            if ($ratioimg == $ratiothumb || $ratiothumb == (float) 1){
-                $this->img["lebar_thumb"]=$width;
-                $this->img["tinggi_thumb"]=$height;
-            } elseif ($ratioimg > $ratiothumb){
-            	$length = max($width, $height);
-                $this->img["lebar_thumb"]=$length;
-                $this->img["tinggi_thumb"]=$length*((float)1/$ratioimg);
-            } elseif ($ratioimg < $ratiothumb){
-            	$length = max($width, $height);
-                $this->img["tinggi_thumb"]=$length;
-                $this->img["lebar_thumb"]=$length*$ratioimg;
-            }
+    
+		/** 
+		 * @private
+		 */
+        function calcThumbFormat($targetWidth, $targetHeight) {
+            
+            // lebar = width
+            // tinggi = height
+            // in malay language
+            
+    	    $ratioimg = $this->img["tinggi"] / $this->img["lebar"];
+    	
+        	if ($ratioimg < $targetHeight / $targetWidth) {
+        	    $this->img["lebar_thumb"] = (int)$targetWidth;
+        	    $this->img["tinggi_thumb"] = (int)round($targetWidth * $ratioimg);
+        	} else {
+        	    $this->img["lebar_thumb"] = (int)round($targetHeight / $ratioimg);
+        	    $this->img["tinggi_thumb"] = (int)$targetHeight;
+        	}
+        	return true;
         }
-        
+           
     }
 ?>

Modified: plog/branches/lifetype-1.2/templates/admin/globalsettings_resources.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/globalsettings_resources.template	2007-10-19 21:07:49 UTC (rev 5991)
+++ plog/branches/lifetype-1.2/templates/admin/globalsettings_resources.template	2007-10-20 14:29:55 UTC (rev 5992)
@@ -48,18 +48,18 @@
       <option value="same" {if $thumbnail_format == "same"} selected="selected" {/if} />{$locale->tr("same_as_image")}</option>	  	  
      </select>
    </div>
+   <!-- thumbnail_width -->
+   <div class="field">
+    <label for="config[thumbnail_width]">thumbnail_width</label>
+    <div class="formHelp">{$locale->tr("help_thumbnail_width")}</div>	
+    <input style="width:100%" type="text" name="config[thumbnail_width]" value="{$thumbnail_width}"/>
+   </div>
    <!-- thumbnail_height -->
    <div class="field">
     <label for="config[thumbnail_height]">thumbnail_height</label>
     <div class="formHelp">{$locale->tr("help_thumbnail_height")}</div>
     <input style="width:100%" type="text" name="config[thumbnail_height]" value="{$thumbnail_height}"/>
    </div>
-   <!-- thumbnail_width -->
-   <div class="field">
-    <label for="config[thumbnail_width]">thumbnail_width</label>
-    <div class="formHelp">{$locale->tr("help_thumbnail_width")}</div>	
-    <input style="width:100%" type="text" name="config[thumbnail_width]" value="{$thumbnail_width}"/>
-   </div>
    <!-- medium_size_thumbnail_width -->
    <div class="field">
     <label for="config[medium_size_thumbnail_width]">medium_size_thumbnail_width</label>
@@ -128,4 +128,4 @@
     <div class="formHelp">{$locale->tr("help_resource_server_http_cache_lifetime")}</div>	
     <input style="width:100%" type="text" name="config[resource_server_http_cache_lifetime]" value="{$resource_server_http_cache_lifetime}"/>
    </div>
-</div>  
\ No newline at end of file
+</div>  



More information about the pLog-svn mailing list