summaryrefslogtreecommitdiff
path: root/forum/utils/imagecache.php
diff options
context:
space:
mode:
authordeva <deva>2008-10-12 17:00:54 +0000
committerdeva <deva>2008-10-12 17:00:54 +0000
commitbf738e366e34c330649a9f36a3b2001231230b3a (patch)
tree9ced926fe91f0dad3a75a0687b119439f898e6f6 /forum/utils/imagecache.php
parent28856d6f9b7d726b1681df9384f3ef000dbf6f4c (diff)
Now the file preview on images are scaled down.
Diffstat (limited to 'forum/utils/imagecache.php')
-rw-r--r--forum/utils/imagecache.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/forum/utils/imagecache.php b/forum/utils/imagecache.php
index 0c18e1a..aa86c97 100644
--- a/forum/utils/imagecache.php
+++ b/forum/utils/imagecache.php
@@ -4,14 +4,13 @@ include_once("config.php");
include_once($UTIL_DIR . "/ping.php");
-function rescale($image) {
-
- $maxwidth = 300;
- $maxheight = 240;
-
+function rescale($image, $maxwidth = 300, $maxheight = 240)
+{
$width = imagesx($image);
$height = imagesy($image);
+ if($width <= $maxwidth && $height <= $maxheight) return $image;
+
$scale = 1;
if($width > $maxwidth) $scale = $width / $maxwidth;
if($height / $scale > $maxheight) $scale = $height / $maxheight;