################################################################################
# #
# create_thumb_file v0.2 & v0.3 is Copyright (c) #
# Written and developed by Christian Zamora 2004. #
# #
# This class is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; either version 2 of the License, or (at your option) #
# any later version. #
# #
# This program is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License #
# for more details. #
# #
# www.corereactor.de #
# #
# edited by Ch. Zamora. #
# #
# Edit Log: #
# - dynamic template extension on template assign #
# - dynamic template directory choose on template assign #
# #
# Note: #
# You'll need at last php4.0 with a compiled gd lib. #
# Version 0.3 needs freetype2 too. #
# #
################################################################################
function create_thumb_file($path, $thpath, $name)
{
$new_w=120;
$new_h=120;
$s = 6;
$path = realpath($path.$name);
$res = GetImageSize($path);
header("Content-type: " . $res[mime]);
$wx = $res[0];
$hx = $res[1];
if ($new_w<=10) { $new_w = $wx; }
if ($new_h<=10) { $new_h = $hx; }
$dst_img=ImageCreateTrueColor($new_w, $new_h);
$src_img=ImageCreateFromJPEG($path);
$col = ImageColorAllocate($src_img, 198, 198, 19
;
ImageCopyResampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
ImageJPEG($dst_img, $thpath . 'th_' . $name);
}
##################### v 0.3 with copyright text #################################
function create_thumb_file($path, $thpath, $name, $text = '', $font='arial.ttf')
{
$new_w=120;
$new_h=120;
$s = 6;
$settext = $text;
$path = realpath($path.$name);
$res = GetImageSize($path);
$font = realpath($font);
header("Content-type: " . $res[mime]);
$wx = $res[0];
$hx = $res[1];
if ($new_w<=10) { $new_w = $wx; }
if ($new_h<=10) { $new_h = $hx; }
$dst_img=ImageCreateTrueColor($new_w, $new_h);
$src_img=ImageCreateFromJPEG($path);
$arr = ImageTTFBBox($s, 0, $font, $settext);
$x = $new_w - $arr[2] - 0;
$y = $new_h - $arr[1] - 0;
$col = ImageColorAllocate($src_img, 198, 198, 19
;
ImageCopyResampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
ImageTTFText($dst_img, $s, 0, $x, $y, $col, $font, $settext);
ImageJPEG($dst_img, $thpath . 'th_' . $name);
}