-=[ Mr. Bumblebee ]=-
_Indonesia_
<?php
class image // only resize
{
var $file_path = '.' ;
var $result_file_name = '' ;
var $thumb_path = '.' ;
var $ext = 'png' ;
var $head = 'thumb_' ;
var $quality = 75 ;
var $width = 30 ;
var $height = 30 ;
function resize ( $target_file )
{
static $target_ext ;
static $target_path ;
static $target_color ;
$target_ext = strtolower ( substr( $target_file , strrpos($target_file , '.' )+1) );
if ( empty($this->ext)) $this->ext = $target_ext ;
if ( !is_file($_SERVER['DOCUMENT_ROOT'] . '/' . $this->file_path . '/' . $target_file)) return ;
switch ( strtolower($target_ext) )
{
case 'jpeg' :
case 'jpg' : $target_path = @ImageCreateFromJPEG( $_SERVER['DOCUMENT_ROOT'] . '/' . $this->file_path . '/' . $target_file ) ; break ;
case 'gif' : $target_path = @ImageCreateFromGIF( $_SERVER['DOCUMENT_ROOT'] . '/' . $this->file_path . '/' . $target_file ) ; break ;
case 'png' : $target_path = @ImageCreateFromPNG( $_SERVER['DOCUMENT_ROOT'] . '/' . $this->file_path . '/' . $target_file ) ; break ;
default : break ;
}
$target_color = ImageCreateTrueColor( $this->width , $this->height ) ;
ImageCopyResampled( $target_color , $target_path , 0 , 0 , 0, 0 , $this->width , $this->height , ImageSX( $target_path ) , ImageSy( $target_path )) ;
$target_file = substr($target_file, 0 , strrpos($target_file , '.') ) . '.' . $this->ext ;
create_dir($this->thumb_path) ;
$this->thumb_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $this->thumb_path ;
$resizefilename = $this->head . $target_file ;
$chk_file = $this->thumb_path . '/' . $resizefilename ;
$tempfilename = $resizefilename ;
$x = 1 ;
while ( @file_exists($chk_file))
{
$tempfilename = $x . '_' . $resizefilename ;
$chk_file = $this->thumb_path . '/' . $tempfilename ;
$x++;
}
$this->result_file_name = $tempfilename ;
$target_file_full_path = $this->thumb_path . '/' . $tempfilename ;
switch ( strtolower($this->ext) )
{
case 'jpeg' :
case 'jpg' : @ImageJPEG ( $target_color , $target_file_full_path , $this->quality) ; break ;
case 'gif' : @ImageGIF ( $target_color , $target_file_full_path , $this->quality) ; break ;
case 'png' : @ImagePNG ( $target_color , $target_file_full_path , $this->quality) ; break ;
}
@ImageDestroy($target_path) ;
@ImageDestroy($target_color) ;
}
}
class resizeimage // resize and save
{
var $result_file_name = '' ;
var $upload_dir = '.' ;
var $resize_quality = 75 ;
var $width = 0 ;
var $height = 0 ;
var $option_fixed = 'N' ;
var $file_format = 'png' ;
function resize ( $obj_file ) {
$objfullfilename = $obj_file['name'] ;
if ( file_effectiveness_check($objfullfilename) === false ) return ;
$objfullfilename = file_effectiveness_name($objfullfilename) ;
$objfileformat = substr( $objfullfilename , strrpos($objfullfilename , '.' ) + 1);
switch ( strtolower($objfileformat)) {
case 'jpeg' :
case 'jpg' : $fullfilepath = @ImageCreateFromJPEG( $obj_file['tmp_name'] ) ; break ;
case 'gif' : $fullfilepath = @ImageCreateFromGIF( $obj_file['tmp_name'] ) ; break ;
case 'png' : $fullfilepath = @ImageCreateFromPNG( $obj_file['tmp_name'] ) ; break ;
default : return ;
}
if ( $this->option_fixed == 'Y' ) {
} else {
$fileinfo = file_getimagesize ( $obj_file['tmp_name'] ) ;
if ( $this->height < 1 ) $this->height = $fileinfo[1] ;
if ( $this->width < 1 ) $this->width = $fileinfo[0] ;
$file_downsize = file_s_size ( $fileinfo[0] , $fileinfo[1] , $this->width , $this->height );
$this->width = $file_downsize['width'] ;
$this->height = $file_downsize['height'] ;
}
$file_truecolor = @ImageCreateTrueColor( $this->width , $this->height ) ;
ImageCopyResampled ( $file_truecolor , $fullfilepath , 0 , 0 , 0 , 0 , $this->width , $this->height , ImageSX( $fullfilepath ) , ImageSy( $fullfilepath )) ;
$resizefilename = substr($objfullfilename, 0 , strrpos($objfullfilename , '.') ) . '.' . $this->file_format ;
create_dir($this->upload_dir) ;
$this->upload_dir = $_SERVER['DOCUMENT_ROOT'] . '/' . $this->upload_dir ;
$chk_file = $this->upload_dir . '/' . $resizefilename ;
$tempfilename = $resizefilename ;
$x = 1 ;
while ( @file_exists($chk_file))
{
$tempfilename = $x . '_' . $resizefilename ;
$chk_file = $this->upload_dir . '/' . $tempfilename ;
$x++;
}
$resizefilename = $this->result_file_name = $tempfilename ;
$resizefullfilepath = $this->upload_dir . '/' . $this->result_file_name ;
switch ( strtolower($this->file_format) )
{
case 'jpeg' :
case 'jpg' : @ImageJPEG ( $file_truecolor , $resizefullfilepath , $this->resize_quality) ; break ;
case 'gif' : @ImageGIF ( $file_truecolor , $resizefullfilepath , $this->resize_quality) ; break ;
case 'png' : @ImagePNG ( $file_truecolor , $resizefullfilepath , $this->resize_quality) ; break ;
}
@ImageDestroy($target_path) ;
@ImageDestroy($file_truecolor) ;
}
}
class resizeimageV2 // resize and save
{
var $result_file_name = '' ;
var $upload_dir = '.' ;
var $resize_quality = 100 ;
var $width = 0 ;
var $height = 0 ;
var $option_fixed = 'N' ;
var $file_format = '' ;
function resize ( $obj_file ) {
$objfullfilename = $obj_file['name'] ;
if ( file_effectiveness_check($objfullfilename) === false ) return ;
$objfullfilename = file_effectiveness_name($objfullfilename) ;
$objfileformat = substr( $objfullfilename , strrpos($objfullfilename , '.' ) + 1);
switch ( strtolower($objfileformat)) {
case 'jpeg' :
case 'jpg' : $fullfilepath = @ImageCreateFromJPEG( $obj_file['tmp_name'] ) ; break ;
case 'gif' : $fullfilepath = @ImageCreateFromGIF( $obj_file['tmp_name'] ) ; break ;
case 'png' : $fullfilepath = @ImageCreateFromPNG( $obj_file['tmp_name'] ) ; break ;
default : return ;
}
$this->file_format = $objfileformat ;
if ( $this->option_fixed == 'Y' ) {
} else {
$fileinfo = file_getimagesize ( $obj_file['tmp_name'] ) ;
if ( $this->height < 1 ) $this->height = $fileinfo[1] ;
if ( $this->width < 1 ) $this->width = $fileinfo[0] ;
$file_downsize = file_s_size ( $fileinfo[0] , $fileinfo[1] , $this->width , $this->height );
$this->width = $file_downsize['width'] ;
$this->height = $file_downsize['height'] ;
}
$file_truecolor = @ImageCreateTrueColor( $this->width , $this->height ) ;
ImageCopyResampled ( $file_truecolor , $fullfilepath , 0 , 0 , 0 , 0 , $this->width , $this->height , ImageSX( $fullfilepath ) , ImageSy( $fullfilepath )) ;
$resizefilename = substr($objfullfilename, 0 , strrpos($objfullfilename , '.') ) . '.' . $this->file_format ;
create_dir($this->upload_dir) ;
$this->upload_dir = $_SERVER['DOCUMENT_ROOT'] . '/' . $this->upload_dir ;
$chk_file = $this->upload_dir . '/' . $resizefilename ;
$tempfilename = $resizefilename ;
$x = 1 ;
while ( @file_exists($chk_file))
{
$tempfilename = $x . '_' . $resizefilename ;
$chk_file = $this->upload_dir . '/' . $tempfilename ;
$x++;
}
$resizefilename = $this->result_file_name = $tempfilename ;
$resizefullfilepath = $this->upload_dir . '/' . $this->result_file_name ;
switch ( strtolower($this->file_format) )
{
case 'jpeg' :
case 'jpg' : @ImageJPEG ( $file_truecolor , $resizefullfilepath , $this->resize_quality) ; break ;
case 'gif' : @ImageGIF ( $file_truecolor , $resizefullfilepath , $this->resize_quality) ; break ;
case 'png' : @ImagePNG ( $file_truecolor , $resizefullfilepath , $this->resize_quality) ; break ;
}
@ImageDestroy($target_path) ;
@ImageDestroy($file_truecolor) ;
}
}
?>
Copyright © 2017 || Recoded By Mr.Bumblebee