summaryrefslogtreecommitdiff
path: root/forum/utils/imagecache.php
diff options
context:
space:
mode:
authordeva <deva>2008-10-12 16:02:03 +0000
committerdeva <deva>2008-10-12 16:02:03 +0000
commit28856d6f9b7d726b1681df9384f3ef000dbf6f4c (patch)
tree4297943b1d5656ee2b0c01d3aabac5ddb414d45d /forum/utils/imagecache.php
parented97119bc3a7203b11d92cf170869a12bd2da953 (diff)
Made file preview (original image or png with filename as text). Added error image as png with error text.
Diffstat (limited to 'forum/utils/imagecache.php')
-rw-r--r--forum/utils/imagecache.php25
1 files changed, 12 insertions, 13 deletions
diff --git a/forum/utils/imagecache.php b/forum/utils/imagecache.php
index ac3ebc3..0c18e1a 100644
--- a/forum/utils/imagecache.php
+++ b/forum/utils/imagecache.php
@@ -22,17 +22,16 @@ function rescale($image) {
return $image_p;
}
-function errorImage($filename)
+function errorImage($message)
{
- /*
- header('Content-Description: File Transfer');
- header('Content-Type: image/jpeg');
- header('Content-Length: ' . filesize($fullfilename));
- header('Content-Disposition: inline; filename=' . basename($filename));
- readfile($fullfilename);
- */
- echo "Error fetching image: " . $filename;
- die(404);
+ header("Content-type: image/png");
+ $im = @imagecreate(8 + strlen($message) * 5, 20)
+ or die("Cannot Initialize new GD image stream");
+ $background_color = imagecolorallocate($im, 0, 0, 0);
+ $text_color = imagecolorallocate($im, 233, 14, 91);
+ imagestring($im, 1, 5, 5, $message, $text_color);
+ imagepng($im);
+ imagedestroy($im);
}
function getCachedImage($filename)
@@ -63,21 +62,21 @@ function getCachedImage($filename)
case ".jpeg":
case ".jpg":
$image = imagecreatefromjpeg(urldecode($filename));
- if(!$image) errorImage($filename);
+ if(!$image) errorImage("Could not read: ". $filename);
$image = rescale($image);
imagejpeg($image, $fullfilename, 90);
break;
case ".gif":
$image = imagecreatefromgif(urldecode($filename));
- if(!$image) errorImage($filename);
+ if(!$image) errorImage("Could not read: ". $filename);
$image = rescale($image);
imagegif($image, $fullfilename);
break;
case ".png":
$image = imagecreatefrompng(urldecode($filename));
- if(!$image) errorImage($filename);
+ if(!$image) errorImage("Could not read: ". $filename);
$image = rescale($image);
imagepng($image, $fullfilename);
break;