public static function createThumb($param)
{
if ($param['image'] != '') {
$root = $_SERVER['DOCUMENT_ROOT'];
$onlyImgLink = urldecode(str_replace($param['imageDir'], '', $param['image']));
$img = $root . '/' . $param['imageDir'] . $onlyImgLink;
if (file_exists($img)) {
// replace space pada gambar
$thumbName = self::cleanImgName($onlyImgLink);
$thumbDir = dirname($root . $param['thumbDir'] . $onlyImgLink);
// get direktori image basename
$thumbDir = self::cleanDirName($thumbDir);
if (!is_dir($thumbDir)) {
// create directory thumb image
mkdir($thumbDir, 0755, true);
}
//create small thumb
if (isset($param['small'])) {
$image = new EasyImage($img);
$image->resize(100, 100, EasyImage::RESIZE_HEIGHT);
$image->crop(100, 100, 0, 0);
$image->save($thumbDir . '/small-' . $thumbName);
}
// create medium thumb
if (isset($param['medium'])) {
$image = new EasyImage($img);
if (!empty($_POST['w'])) {
$image->crop($_POST['w'], $_POST['h'], $_POST['x1'], $_POST['y1']);
} else {
$image->crop(400, 200, 0, 0);
}
$image->resize(400, 200, EasyImage::RESIZE_WIDTH);
$image->save($thumbDir . '/medium-' . $thumbName);
}
// create medium thumb
if (isset($param['large'])) {
$image = new EasyImage($img);
if (!empty($_POST['w'])) {
$image->crop($_POST['w'], $_POST['h'], $_POST['x1'], $_POST['y1']);
} else {
$image->crop(650, 400, 0, 0);
}
$image->resize(650, 400, EasyImage::RESIZE_WIDTH);
$image->save($thumbDir . '/large-' . $thumbName);
}
}
}
}