| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/m.musiccircle/webadmin/ |
Upload File : |
<?php
function createthumb($name, $filename, $new_w, $new_h)
{
$width = getWidth($filename);
$height = getHeight($filename);
if ($width > $height) {
if ($width > $new_w) {
$scale = $new_w / $width;
} elseif ($height > $new_h) {
$scale = $new_h / $height;
} else {
$scale = 1;
}
} else {
if ($height > $new_h) {
$scale = $new_h / $height;
} elseif ($width > $new_w) {
$scale = $new_w / $width;
} else {
$scale = 1;
}
}
$name = resizeImage($filename, $width, $height, $scale);
}
//You do not need to alter these functions
function getHeight($image)
{
$size = getimagesize($image);
$height = $size[1];
return $height;
}
//You do not need to alter these functions
function getWidth($image)
{
$size = getimagesize($image);
$width = $size[0];
return $width;
}
function resizeImage($image, $width, $height, $scale)
{
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
$imageType = image_type_to_mime_type($imageType);
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
// Make the background transparent
if ($imageType == 'image/gif') {
$transparent = imagecolorallocate($newImage, 0, 0, 0);
imagecolortransparent($newImage, $transparent);
} else {
imagealphablending($newImage, false);
imagesavealpha($newImage, true);
$trans_colour = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
imagefill($newImage, 0, 0, $trans_colour);
}
switch ($imageType) {
case "image/gif":
$source = imagecreatefromgif($image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source = imagecreatefromjpeg($image);
break;
case "image/png":
case "image/x-png":
$source = imagecreatefrompng($image);
break;
}
imagecopyresampled($newImage, $source, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $width, $height);
switch ($imageType) {
case "image/gif":
imagegif($newImage, $image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($newImage, $image, 100);
break;
case "image/png":
case "image/x-png":
imagepng($newImage, $image);
break;
}
//chmod($image, 0775);
return $image;
}
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale)
{
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
$imageType = image_type_to_mime_type($imageType);
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
// Make the background transparent
if ($imageType == 'image/gif') {
$transparent = imagecolorallocate($newImage, 0, 0, 0);
imagecolortransparent($newImage, $transparent);
} else {
imagealphablending($newImage, false);
imagesavealpha($newImage, true);
$trans_colour = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
imagefill($newImage, 0, 0, $trans_colour);
}
switch ($imageType) {
case "image/gif":
$source = imagecreatefromgif($image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source = imagecreatefromjpeg($image);
break;
case "image/png":
case "image/x-png":
$source = imagecreatefrompng($image);
break;
}
imagecopyresampled($newImage, $source, 0, 0, $start_width, $start_height, $newImageWidth, $newImageHeight, $width, $height);
switch ($imageType) {
case "image/gif":
imagegif($newImage, $thumb_image_name);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($newImage, $thumb_image_name, 100);
break;
case "image/png":
case "image/x-png":
imagepng($newImage, $thumb_image_name);
break;
}
//chmod($thumb_image_name, 0775);
return $thumb_image_name;
}
?>