21 $absPath = str_replace(
'\\',
'/',realpath(dirname(__FILE__))).
'/';
29 define(
'NO_PREVIEW',
'inc/img/no_preview.png');
40 if (file_exists($path)) {
42 list($imgWidth, $imgHeight, $imgType) = getImageSize($path);
45 $img = ImageCreateFromGIF($path);
48 $img = ImageCreateFromJPEG($path);
51 $img = ImageCreateFromPNG($path);
54 return isset($img) ? $img : FALSE;
75 list($imgWidth, $imgHeight, $imgType) = getImageSize($path);
76 $imgRatio = $imgWidth/$imgHeight;
94 if (($imgType == IMAGETYPE_GIF) || ($imgType == IMAGETYPE_PNG)) {
95 $transparentIndex = imageColorTransparent($img);
96 if ($transparentIndex >= 0) {
97 $transparentColor = imageColorsForIndex($img, $transparentIndex);
98 $transparentIndex = imageColorAllocate($newImg, $transparentColor[
'red'], $transparentColor[
'green'], $transparentColor[
'blue']);
99 imageFill($newImg, 0, 0, $transparentIndex);
100 imageColorTransparent($newImg, $transparentIndex);
103 if ($imgType == IMAGETYPE_PNG) {
104 imageAlphaBlending($newImg, FALSE);
105 $color = imageColorAllocateAlpha($newImg, 0, 0, 0, 127);
106 imageFill($newImg, 0, 0, $color);
107 imageSaveAlpha($newImg, TRUE);
113 ImageCopyResampled($newImg, $img, 0, 0, 0 , 0,
$width,
$height, $imgWidth, $imgHeight);
136 function saveImage($img, $path, $extension, $quality=100) {
137 switch ($extension) {
139 return imageJpeg($img,$path,$quality);
142 return imageGif($img,$path);
145 return imagePng($img,$path);
153 $maxHeight = (isset($_GET[
'max_height']) && ctype_digit($_GET[
'max_height'])) ? $_GET[
'max_height'] : 60;
155 $maxWidth = (isset($_GET[
'max_width']) && ctype_digit($_GET[
'max_width'])) ? $_GET[
'max_width'] : 120;
161 header(
"Content-Type: image/png");
165 $scaledImgFilename = $pathParts[
'dirname'].
'/_scaled/'.$pathParts[
'filename'].
'_'.
$maxWidth.
'x'.
$maxHeight.
'.png';
168 if (file_exists(
ABS_PATH.$scaledImgFilename)) {
171 imageAlphaBlending($img, FALSE);
172 imageSaveAlpha($img, TRUE);
176 if (file_exists(
ABS_PATH.$filename)) {
186 imageAlphaBlending($img, FALSE);
187 imageSaveAlpha($img, TRUE);
195 imageAlphaBlending($img, FALSE);
196 imageSaveAlpha($img, TRUE);