-
Notifications
You must be signed in to change notification settings - Fork 0
/
thumb.php
41 lines (34 loc) · 873 Bytes
/
thumb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
define('CL_ROOT', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR));
function getArrayVal(array $array, $name)
{
if (array_key_exists($name, $array))
{
return $array[$name];
}
}
error_reporting(0);
$pic = getArrayVal($_GET,"pic");
$height = getArrayVal($_GET,"height");
$width = getArrayVal($_GET,"width");
include(CL_ROOT . "/include/class.hft_image.php");
$imagehw = GetImageSize($pic);
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
$myThumb = new hft_image(CL_ROOT . "/" . $pic);
$myThumb->jpeg_quality = 80;
if (!isset($height))
{
$ratio = $imageheight / $imagewidth;
$height = $width * $ratio;
$height = round($height);
}
if (!isset($width))
{
$ratio = $imagewidth / $imageheight;
$width = $height * $ratio;
}
$myThumb->resize($width, $height, 0);
HEADER("Content-Type: image/jpeg");
$myThumb->output_resized("");
?>