Server IP : 103.119.228.120 / Your IP : 18.218.2.191 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/hendraso/public_html/Library/ |
Upload File : |
<?php /* Creator : Ageng / 11 Maret 2022 */ CLASS Image { public static function resize($name, $width = 200, $height = false, $copy_to = false, $type = false) { $class_image = new Image(); $size = $class_image->setSize($name, $width, $height, $type); if(!empty($size['w']) && !empty($size['h'])) { $src_logo = $size['src_img']; $thumb_w = $size['w']; $thumb_h = $size['h']; $old_x = $size['old_x']; $old_y = $size['old_y']; $process_img = imagecreatetruecolor($thumb_w, $thumb_h); // ==== SET jika image Transparent ======= imagealphablending($process_img, false); imagesavealpha($process_img,true); $transparent = imagecolorallocatealpha($process_img, 255, 255, 255, 127); imagefilledrectangle($process_img, 0, 0, $thumb_w, $thumb_h, $transparent); // ========================== imagecopyresampled($process_img, $src_logo, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); $class_image->process_image($size['type'], $process_img, $copy_to); imagedestroy($src_logo); imagedestroy($process_img); }else{ echo json_encode(array("status" => 406, "content" => "Please check image!"));die; } } public static function crop($name, $width = 200, $height = false, $copy_to = false, $type = false) { $class_image = new Image(); $size = $class_image->setSize($name, $width, $height, $type); if(!empty($size['w']) && !empty($size['h'])) { $src_logo = $size['src_img']; $thumb_w = $size['w']; $thumb_h = $size['h']; $old_x = $size['old_x']; $old_y = $size['old_y']; $logo_img = imagecreatetruecolor($thumb_w, $thumb_h); // ==== SET jika image Transparent ======= imagealphablending($logo_img, false); imagesavealpha($logo_img,true); $transparent = imagecolorallocatealpha($logo_img, 255, 255, 255, 127); imagefilledrectangle($logo_img, 0, 0, $thumb_w, $thumb_h, $transparent); // ========================== imagecopyresampled($logo_img, $src_logo, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); $new_w = $thumb_w; $new_h = $thumb_h; $offset_crop = $class_image->setCrop($width, $height, $new_w, $new_h); $x1 = $offset_crop['x']; $y1 = $offset_crop['y']; $process_img = ImageCreateTrueColor($width, $height); imagealphablending($process_img, false); imagesavealpha($process_img,true); $transparent = imagecolorallocatealpha($process_img, 255, 255, 255, 127); imagefilledrectangle($process_img, 0, 0, $width , $height, $transparent); imagecopyresampled($process_img, $logo_img,0 ,0 ,$x1, $y1, $width, $height, $width, $height); $class_image->process_image($size['type'], $process_img, $copy_to); imagedestroy($src_logo); imagedestroy($logo_img); imagedestroy($process_img); }else{ echo json_encode(array("status" => 406, "content" => "Please check image!"));die; } } function process_image($type, $process_img, $copy_to = false) { $filepath_cache = dirname(__DIR__) . "/Assets/img/cache/".substr(strrchr($_SERVER['REQUEST_URI'], '/'), 1); if ( preg_match('/jpg|jpeg/', $type) ) { if($copy_to) { imagejpeg($process_img, $copy_to); }else{ header("Content-type: {$type}"); imagejpeg($process_img); imagejpeg($process_img, $filepath_cache); } } if ( preg_match('/png/', $type) ) { if($copy_to) { imagepng($process_img, $copy_to); }else{ header("Content-type: {$type}"); imagepng($process_img); imagepng($process_img, $filepath_cache); } } if ( preg_match('/gif/', $type) ) { if($copy_to) { imagegif($process_img, $copy_to); }else{ header('Content-type: image/gif'); imagegif($process_img); imagegif($process_img, $filepath_cache); } } } function setCrop($width, $height, $new_width, $new_height) { $selisih_w = 0; $selisih_h = 0; if($new_width > $width) { $selisih_w = ($new_width - $width) / 2; $selisih_h = 0; }elseif($new_height > $height) { $selisih_w = 0; $selisih_h = ($new_height - $height) / 2; } return array("x" => $selisih_w, "y" => $selisih_h); } function setSize($name, $w = 150, $h = false, $type = false){ $type = "jpg"; if ( preg_match('/jpg|jpeg/', (($type) ? $type : $name)) ) { $src_img = imagecreatefromjpeg($name); $type = "image/jpeg"; } if ( preg_match('/png/', (($type) ? $type : $name)) ) { $src_img = imagecreatefrompng($name); $type = "image/png"; } if ( preg_match('/gif/', (($type) ? $type : $name)) ) { $src_img = imagecreatefromgif($name); $type = "image/gif"; } $new_w = ($w > $h) ? $w : $h; $new_h = ($h) ? (($w > $h) ? $w : $h) : $new_w; $old_x = imageSX($src_img); $old_y = imageSY($src_img); $thumb_w = $new_w; $thumb_h = $old_y * ($new_h / $old_x); if($old_x > $old_y) { $thumb_w = $new_w; $thumb_h = $old_y * ($new_h / $old_x); }elseif($old_x < $old_y) { $thumb_w = $old_x * ($new_w / $old_y); $thumb_h = $new_h; }else { $thumb_w = $new_w; $thumb_h = $new_h; } $selisih = 0; if($thumb_h < $h) { $selisih = $h - $thumb_h; }elseif($thumb_w < $w) { $selisih = $w - $thumb_w; } $thumb_h = $thumb_h + $selisih; $thumb_w = $thumb_w + $selisih; return array("src_img" => $src_img, "w" => $thumb_w, "h" => $thumb_h, "old_x" => $old_x, "old_y" => $old_y, "type" => $type); } }