[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7099] Frontend: auto resize picture
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7099] Frontend: auto resize picture |
Date: |
Wed, 09 Mar 2011 11:55:15 +0000 |
Revision: 7099
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7099
Author: sigurdne
Date: 2011-03-09 11:55:14 +0000 (Wed, 09 Mar 2011)
Log Message:
-----------
Frontend: auto resize picture
Modified Paths:
--------------
trunk/frontend/inc/class.uifrontend.inc.php
Modified: trunk/frontend/inc/class.uifrontend.inc.php
===================================================================
--- trunk/frontend/inc/class.uifrontend.inc.php 2011-03-09 08:14:06 UTC (rev
7098)
+++ trunk/frontend/inc/class.uifrontend.inc.php 2011-03-09 11:55:14 UTC (rev
7099)
@@ -479,12 +479,21 @@
{
$mime_type = $ls_array[0]['mime_type'];
}
-
+
if(isset($document) && $document != '')
{
header('Content-type: ' . $mime_type);
- echo $document;
+ if(function_exists('imagejpeg'))
+ {
+ $source =
"{$GLOBALS['phpgw_info']['server']['files_dir']}{$ls_array[0]['directory']}/{$ls_array[0]['name']}";
+ $this->create_thumb($source,173);
+ }
+ else
+ {
+ echo $document;
+ }
+
$GLOBALS['phpgw']->common->phpgw_exit();
}
else
@@ -492,4 +501,47 @@
$GLOBALS['phpgw']->redirect_link('templates/base/images/missing_picture.png');
}
}
+
+ function create_thumb($source,$target_height = 100)
+ {
+ $size = getimagesize($source);
+ $width = $size[0];
+ $height = $size[1];
+
+ $target_width = round($width*($target_height/$height));
+
+ if ($width > $height)
+ {
+ $x = ceil(($width - $height) / 2 );
+ $width = $height;
+ }
+ else if($height > $width)
+ {
+ $y = ceil(($height - $width) / 2);
+ $height = $width;
+ }
+
+ $new_im =
ImageCreatetruecolor($target_width,$target_height);
+
+ @$imgInfo = getimagesize($source);
+
+ if ($imgInfo[2] == IMAGETYPE_JPEG)
+ {
+ $im = imagecreatefromjpeg($source);
+
imagecopyresampled($new_im,$im,0,0,$x,$y,$target_width,$target_height,$width,$height);
+ imagejpeg($new_im,$dest,75); // Thumbnail
quality (Value from 1 to 100)
+ }
+ else if ($imgInfo[2] == IMAGETYPE_GIF)
+ {
+ $im = imagecreatefromgif($source);
+
imagecopyresampled($new_im,$im,0,0,$x,$y,$target_width,$target_height,$width,$height);
+ imagegif($new_im,$dest);
+ }
+ else if ($imgInfo[2] == IMAGETYPE_PNG)
+ {
+ $im = imagecreatefrompng($source);
+
imagecopyresampled($new_im,$im,0,0,$x,$y,$target_width,$target_height,$width,$height);
+ imagepng($new_im,$dest);
+ }
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7099] Frontend: auto resize picture,
Sigurd Nes <=