incubator-olio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r814822 - in /incubator/olio/webapp/php/trunk: classes/ImageUtil.php public_html/addEventResult.php public_html/addPersonResult.php
Date Mon, 14 Sep 2009 20:05:49 GMT
Author: shanti
Date: Mon Sep 14 20:05:48 2009
New Revision: 814822

URL: http://svn.apache.org/viewvc?rev=814822&view=rev
Log:
Fix for OLIO-108. Replaced call to 'imageCopyResampled' with 'fastImageCopyResampled'. Also

changed thumbnail size to be slightly more consistent with initial thumbnails.

Modified:
    incubator/olio/webapp/php/trunk/classes/ImageUtil.php
    incubator/olio/webapp/php/trunk/public_html/addEventResult.php
    incubator/olio/webapp/php/trunk/public_html/addPersonResult.php

Modified: incubator/olio/webapp/php/trunk/classes/ImageUtil.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/classes/ImageUtil.php?rev=814822&r1=814821&r2=814822&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/classes/ImageUtil.php (original)
+++ incubator/olio/webapp/php/trunk/classes/ImageUtil.php Mon Sep 14 20:05:48 2009
@@ -43,7 +43,7 @@
             $thumb_h=$new_h;
         }
         $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
-        imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
+        fastimagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y,3.25);

         if ($img_type == "png") {
             imagepng($dst_img, $thumbname); 
         } else {
@@ -52,5 +52,30 @@
         imagedestroy($dst_img); 
         imagedestroy($src_img); 
     }
+
+    function fastimagecopyresampled (&$dst_image, $src_image, $dst_x, $dst_y, $src_x,
$src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 3) {
+      // Plug-and-Play fastimagecopyresampled function replaces much slower imagecopyresampled.
+      // Just include this function and change all "imagecopyresampled" references to "fastimagecopyresampled".
+      // Typically from 30 to 60 times faster when reducing high resolution images down to
thumbnail size using the default quality setting.
+      // Author: Tim Eckel - Date: 09/07/07 - Version: 1.1 - Project: FreeRingers.net - Freely
distributable - These comments must remain.
+      //
+      // Optional "quality" parameter (defaults is 3). Fractional values are allowed, for
example
+    1.5. Must be greater than zero.
+      // Between 0 and 1 = Fast, but mosaic results, closer to 0 increases the mosaic effect.
+      // 1 = Up to 350 times faster. Poor results, looks very similar to imagecopyresized.
+      // 2 = Up to 95 times faster.  Images appear a little sharp, some prefer this over
a quality of 3.
+      // 3 = Up to 60 times faster.  Will give high quality smooth results very close to
imagecopyresampled, just faster.
+      // 4 = Up to 25 times faster.  Almost identical to imagecopyresampled for most images.
+      // 5 = No speedup. Just uses imagecopyresampled, no advantage over imagecopyresampled.
+    
+      if (empty($src_image) || empty($dst_image) || $quality <= 0) { return false; }
+      if ($quality < 5 && (($dst_w * $quality) < $src_w || ($dst_h * $quality)
< $src_h)) {
+        $temp = imagecreatetruecolor ($dst_w * $quality + 1, $dst_h * $quality + 1);
+        imagecopyresized ($temp, $src_image, 0, 0, $src_x, $src_y, $dst_w * $quality + 1,
$dst_h * $quality + 1, $src_w, $src_h);
+        imagecopyresampled ($dst_image, $temp, $dst_x, $dst_y, 0, 0, $dst_w, $dst_h, $dst_w
* $quality, $dst_h * $quality);
+        imagedestroy ($temp);
+      } else imagecopyresampled ($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y,
$dst_w, $dst_h, $src_w, $src_h);
+      return true;
+    }
 }
 ?>

Modified: incubator/olio/webapp/php/trunk/public_html/addEventResult.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/addEventResult.php?rev=814822&r1=814821&r2=814822&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/addEventResult.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/addEventResult.php Mon Sep 14 20:05:48 2009
@@ -221,7 +221,7 @@
         throw new Exception("Error moving uploaded file to $modified_image_name");
     }
     $thumb_location = $resourcedir . $imagethumb;
-    ImageUtil::createThumb($user_image_location, $thumb_location, 133, 99);
+    ImageUtil::createThumb($user_image_location, $thumb_location, 120, 120);
     if (!isset($fs))
     $fs = FileSystem::getInstance();
     if (!$fs->create($user_image_location, "NO_OP", "NO_OP")) {

Modified: incubator/olio/webapp/php/trunk/public_html/addPersonResult.php
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/php/trunk/public_html/addPersonResult.php?rev=814822&r1=814821&r2=814822&view=diff
==============================================================================
--- incubator/olio/webapp/php/trunk/public_html/addPersonResult.php (original)
+++ incubator/olio/webapp/php/trunk/public_html/addPersonResult.php Mon Sep 14 20:05:48 2009
@@ -128,7 +128,7 @@
 
     // 6. Generate the thumbnails.
     $thumb_location = $resourcedir . $imagethumb;
-    ImageUtil::createThumb($user_image_location, $thumb_location, 133, 99);
+    ImageUtil::createThumb($user_image_location, $thumb_location, 120, 120);
 
     // 7. Store the image.
     $fs = FileSystem::getInstance();



Mime
View raw message