Source for file image.class.php
Documentation is available at image.class.php
* @package Template Engine
* Upload file to directory, if name is not empty rename file (no extension needed)
* @param string $new_name
public function fileUpload($obj, $path, $new_name=
'')
//if there is not new name we keep the same origin name
$name =
$_FILES[$obj]['name'];
$extent =
pathinfo($_FILES[$obj]['name']);
$extent =
$extent['extension'];
$name =
$new_name.
".$extent";
* Assign image to thumbnail file
* @param string path full path with image name
* Transform image to thumbnail file
* @param int $width image width
* @param int $height image height
* @param boolean $contraint
* @param array $background_color 3 colors RGB
* @param string $suffix add a suffix in image name
* @param string $force_type convert original image: jpg, gif, png
public function imgThumbnail($width, $height, $constraint=
false, $background_color=
array(0,0,0), $suffix=
'', $force_type=
'')
$file_name_output =
str_replace(".$file_ext", "$suffix.$force_type", $file_name_output);
// width is larger than height
$thumb_h =
$old_y *
($width /
$old_x);
$thumb_w =
$old_x *
($height /
$old_y);
$thumb_w = (int)
$thumb_w;
$thumb_h = (int)
$thumb_h;
$thumb_h =
$thumb_h *
($width /
$thumb_w);
$thumb_w =
$thumb_w *
($height /
$thumb_h);
$thumb_w = (int)
$thumb_w;
$thumb_h = (int)
$thumb_h;
imagecopyresampled($img_resampled, $srcImg, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
$posX = (int)
(($width -
$thumb_w)/
2);
$posY = (int)
(($height -
$thumb_h)/
2);
$red =
imagecolorallocate($img_resampled, $background_color[0], $background_color[1], $background_color[2]);
//$background = imagecolorallocate($img_resampled, $background_color[0], $background_color[1], $background_color[2]);
imagecopyresampled($img_resampled, $srcImg, $posX, $posY, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
// output with new prefix ?
if($force_type ==
'jpg')imagejpeg($img_resampled, $p.
"/".
$file_name_output, 100);
elseif($force_type ==
'png')imagepng($img_resampled, $p.
"/".
$file_name_output);
elseif($force_type ==
'gif')imagegif($img_resampled, $p.
"/".
$file_name_output);
Documentation generated on Sat, 06 Mar 2010 21:33:58 +0100 by phpDocumentor 1.4.3