merhaba arkadaslar benim bir upload sinifim var ve bu upload sinifi resimleri yuklerken 480x360 ve arkaya beyaz renk ekleyerek yukliyor benim istedigim resimi orjinal boyutunda yuklesin asagidaki koda boyutlar yaziyor ama ne yazacagimi bilmiyorum resim boyutu orjinal yuklesin... tesekurler....
Class Upload {
public $image;
public $copy_klasor = 'ilanlar';
public $font = 'font/Arial.TTF'; // Font Yolu
public $yazi = 'www.vaybe.co.uk';
public $kabul_mime = array("image/jpeg","image/jpg","image/png","image/gif");
public $max_size = 999999999999999999999;
public $min_size = 2048;
public $size;
public $yeniAd;
public $uzanti_bas;
public $get_image_size;
public $gelen_yerim;
public $orj_width;
public $orj_height;
public $mime;
public $hd_mi = false;
public $max_width = 20000;
public $max_height = 20000;
// max -->
public $max_maxwidth = 480;
public $max_maxheight = 360;
public $max_en_oran;
public $max_boy_oran;
public $max_son_en;
public $max_son_boy;
public $thumb_max;
public $source_max;
// max <--
// max -->
public $donen_yeniAd;
public $donen_resim_ad_max;
public $donen_resim_ad_min;
public $donen_resim_ad_hd;
public $donecek_resim_max;
public $donecek_resim_min;
public $donecek_resim_hd;
public $aci;
public $error = array(
'genişlik büyük',
'yükseklik büyük',
'uzantı_sorunu',
'boyut_cok_buyuk',
'boyut_cok_kucuk'
);
public function yukle($gelen_resim,$gelen_yer,$gelen_tip,$gelen_size,$names,$i){
$this -> get_image_size = getimagesize($gelen_yer); // resim tüm bilgileri
$this -> orj_width = $this -> get_image_size[0];
$this -> orj_height = $this -> get_image_size[1];
$this -> mime = $this -> get_image_size['mime'];
$this -> size = $gelen_size;
$this -> image = $gelen_resim;
$this -> gelen_yerim= $gelen_yer;
$this -> yeniAd = $names.'_'.$i;
$this -> _uzanti_bas($this -> mime);
$this -> yeniAd .= $this -> uzanti_bas;
// hd mi kontrol
if( ( $this -> get_image_size[0] >= 600 ) || ( $this -> get_image_size[1] >= 500 ) ){
$this -> hd_mi = true;
}
if($this -> orj_width <= $this -> max_width) {
if($this -> orj_height <= $this -> max_height){
if(in_array($this -> mime,$this -> kabul_mime)){
if($this -> size > $this -> min_size){
if($this -> size < $this -> max_size){
$this->resim_min();
if($this -> hd_mi){
$this -> resim_hd();
}
$this->resim_max();
} else {
echo $this -> error[3];
}
} else {
echo $this -> error[4];
}
} else {
echo $this -> error[2];
}
} else {
// yükseklik büyük
echo $this -> error[1];
}
} else {
// genişlik büyük
echo $this -> error[0];
}
}
public function _uzanti_bas($type){
// "image/jpeg","image/jpg","image/png","image/gif"
switch($type){
case "image/jpeg":
$this -> uzanti_bas = ".jpg";
break;
case "image/jpg":
$this -> uzanti_bas = ".jpg";
break;
case "image/png":
$this -> uzanti_bas = ".png";
break;
case "image/gif":
$this -> uzanti_bas = ".gif";
break;
case "image/gif":
$this -> uzanti_bas = ".JPG";
break;
}
}
public function resim_hd (){
$this -> oran_setting_hd();
$this -> thumb_hd = ImageCreateTrueColor($this->hd_maxwidth,$this -> hd_maxheight);
$this -> source_hd = $this -> _image_create();
$beyaz = ImageColorAllocate($this -> thumb_hd,255,255,255);
ImageFill($this -> thumb_hd,0,0,$beyaz);
imagecopyresampled(
$this -> thumb_hd,
$this -> source_hd,
( ( $this -> hd_maxwidth - $this -> hd_son_en ) / 2 ), // resimi yatay ortala
( ( $this -> hd_maxheight - $this -> hd_son_boy ) / 2 ), // resimi dikey ortala
0,0,$this -> hd_son_en,$this -> hd_son_boy, $this -> get_image_size['0'],$this -> get_image_size['1']
);
$this -> _yazi_yaz($this -> thumb_hd,$this -> hd_son_en, $this -> hd_son_boy,$this -> hd_maxwidth);
$this -> resim_bas_hd($this -> thumb_hd);
$this -> resim_destroy($this -> thumb_hd);
}
public function oran_setting_hd(){
$this -> hd_en_oran = $this -> hd_maxwidth / $this -> get_image_size['0']; // genişlik
$this -> hd_boy_oran = $this -> hd_maxheight / $this -> get_image_size['1']; // yükseklik
if( ( $this -> get_image_size['0'] <= $this -> hd_maxwidth ) && ( $this -> get_image_size['1'] <= $this -> hd_maxheight ) ) {
$this -> hd_son_en = $this -> get_image_size['0'];
$this -> hd_son_boy = $this -> get_image_size['1'];
} else if ( ( $this -> hd_en_oran * $this -> get_image_size['1'] ) < $this -> hd_maxheight ) {
$this -> hd_son_en = $this -> hd_maxwidth;
$this -> hd_son_boy = ceil( $this -> hd_en_oran * $this -> get_image_size['1'] );
} else {
$this -> hd_son_en = ceil( $this -> hd_boy_oran * $this -> get_image_size['0'] );
$this -> hd_son_boy = $this -> hd_maxheight;
}
}
public function _yazi_yaz($thumb,$sonEn,$sonBoy,$orj_resimEn) {
$seffaf_beyaz = imagecolorallocatealpha($thumb, 255,255,255,"70");
$seffaf_siyah = imagecolorallocatealpha($thumb, 0,0,0,"90");
imagettftext($thumb, ($sonEn / 17),30,(((($orj_resimEn - $sonEn) / 30)+ ($sonEn/20))+2),(($sonBoy / 5)+($sonEn/2)+3),$seffaf_siyah,$this -> font,$this -> yazi);
imagettftext($thumb, ($sonEn / 17),30,((($orj_resimEn - $sonEn) / 30)+ ($sonEn/20)),(($sonBoy / 5)+($sonEn/2)),$seffaf_beyaz,$this -> font,$this -> yazi);
}
public function resim_bas_hd($thumb,$ek = null){
if($ek == null) {
$ek = "hd";
}
$this -> _klasorOlustur();
switch($this -> get_image_size['mime']) {
default:
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_hd_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/jpg":
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_hd_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/jpeg":
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_hd_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/png":
$kod = imagepng($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd);
$this -> yeni_hd_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/gif":
$kod = imagegif($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_hd_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
}
return $kod;
}
public function _image_create(){
switch($this -> get_image_size['mime']){
default:
$kod = imagecreatefromjpeg($this -> gelen_yerim);
break;
case"image/jpeg":
$kod = imagecreatefromjpeg($this -> gelen_yerim);
break;
case"image/jpg":
$kod = imagecreatefromjpeg($this -> gelen_yerim);
break;
case"image/png":
$kod = imagecreatefrompng($this -> gelen_yerim);
break;
case"image/gif":
$kod = imagecreatefromgif($this -> gelen_yerim);
break;
}
return $kod;
}
public function _klasorOlustur() {
$gun = date("d");
$ay = date("m");
$yil = date("Y");
$this -> yeniKlasor = $this -> copy_klasor;
}
public function oran_setting_max(){
$this -> max_en_oran = $this -> max_maxwidth / $this -> get_image_size['0']; // genişlik
$this -> max_boy_oran = $this -> max_maxheight / $this -> get_image_size['1']; // yükseklik
if( ( $this -> get_image_size['0'] <= $this -> max_maxwidth ) && ( $this -> get_image_size['1'] <= $this -> max_maxheight ) ) {
$this -> max_son_en = $this -> get_image_size['0'];
$this -> max_son_boy = $this -> get_image_size['1'];
} else if ( ( $this -> max_en_oran * $this -> get_image_size['1'] ) < $this -> max_maxheight ) {
$this -> max_son_en = $this -> max_maxwidth;
$this -> max_son_boy = ceil( $this -> max_en_oran * $this -> get_image_size['1'] );
} else {
$this -> max_son_en = ceil( $this -> max_boy_oran * $this -> get_image_size['0'] );
$this -> max_son_boy = $this -> max_maxheight;
}
}
public function oran_setting_min(){
$this -> min_en_oran = $this -> min_maxwidth / $this -> get_image_size['0']; // genişlik
$this -> min_boy_oran = $this -> min_maxheight / $this -> get_image_size['1']; // yükseklik
if( ( $this -> get_image_size['0'] <= $this -> min_maxwidth ) && ( $this -> get_image_size['1'] <= $this -> min_maxheight ) ) {
$this -> min_son_en = $this -> get_image_size['0'];
$this -> min_son_boy = $this -> get_image_size['1'];
} else if ( ( $this -> min_en_oran * $this -> get_image_size['1'] ) < $this -> min_maxheight ) {
$this -> min_son_en = $this -> min_maxwidth;
$this -> min_son_boy = ceil( $this -> min_en_oran * $this -> get_image_size['1'] );
} else {
$this -> min_son_en = ceil( $this -> min_boy_oran * $this -> get_image_size['0'] );
$this -> min_son_boy = $this -> min_maxheight;
}
}
public function resim_max (){
$this -> oran_setting_max();
$this -> thumb_max = ImageCreateTrueColor($this->max_maxwidth,$this -> max_maxheight);
$this -> source_max = $this -> _image_create();
$beyaz = ImageColorAllocate($this -> thumb_max,255,255,255);
ImageFill($this -> thumb_max,0,0,$beyaz);
imagecopyresampled(
$this -> thumb_max,
$this -> source_max,
( ( $this -> max_maxwidth - $this -> max_son_en ) / 2 ), // resimi yatay ortala
( ( $this -> max_maxheight - $this -> max_son_boy ) / 2 ), // resimi dikey ortala
0,0,$this -> max_son_en,$this -> max_son_boy, $this -> get_image_size['0'],$this -> get_image_size['1']
);
$this -> _yazi_yaz($this -> thumb_max,$this -> max_son_en, $this -> max_son_boy,$this -> max_maxwidth);
$this -> resim_bas_max($this -> thumb_max,"max");
$this -> resim_destroy($this -> thumb_max);
}
public function resim_min (){
$this -> oran_setting_min();
$this -> thumb_min = ImageCreateTrueColor($this->min_maxwidth,$this -> min_maxheight);
$this -> source_min = $this -> _image_create();
$beyaz = ImageColorAllocate($this -> thumb_min,255,255,255);
ImageFill($this -> thumb_min,0,0,$beyaz);
imagecopyresampled(
$this -> thumb_min,
$this -> source_min,
( ( $this -> min_maxwidth - $this -> min_son_en ) / 2 ), // resimi yatay ortala
( ( $this -> min_maxheight - $this -> min_son_boy ) / 2 ), // resimi dikey ortala
0,0,$this -> min_son_en,$this -> min_son_boy, $this -> get_image_size['0'],$this -> get_image_size['1']
);
$this -> resim_bas_min($this -> thumb_min,"min");
$this -> resim_destroy($this -> thumb_min);
}
public function resim_bas_max($thumb,$ek = null){
if($ek == null) {
$ek = "max";
}
$this -> _klasorOlustur();
switch($this -> get_image_size['mime']) {
default:
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_max_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/jpg":
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_max_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/jpeg":
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_max_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/png":
$kod = imagepng($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd);
$this -> yeni_max_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
case"image/gif":
$kod = imagegif($thumb,$this -> yeniKlasor.'/'.$this -> yeniAd,100);
$this -> yeni_max_image = $this -> yeniKlasor.'/'.$this -> yeniAd;
break;
}
return $kod;
}
public function resim_bas_min($thumb,$ek = null){
if($ek == null) {
$ek = "min";
}
$this -> _klasorOlustur();
switch($this -> get_image_size['mime']) {
default:
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd,100);
$this -> yeni_min_image = $this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd;
break;
case"image/jpg":
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd,100);
$this -> yeni_min_image = $this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd;
break;
case"image/jpeg":
$kod = imagejpeg($thumb,$this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd,100);
$this -> yeni_min_image = $this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd;
break;
case"image/png":
$kod = imagepng($thumb,$this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd);
$this -> yeni_min_image = $this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd;
break;
case"image/gif":
$kod = imagegif($thumb,$this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd,100);
$this -> yeni_min_image = $this -> yeniKlasor.'/'.$ek.'_'.$this -> yeniAd;
break;
}
return $kod;
}
public function resim_destroy($thumb) {
imagedestroy($thumb);
}
public function image_refresh($aci,$resim_hd,$resim_max,$resim_min,$type = null,$get){
switch($type){
default:
$this -> donen_yeniAd = $get;
$source_1 = imagecreatefromjpeg($resim_max);
break;
case "image/jpeg":
$this -> donen_yeniAd = $get;
$source_1 = imagecreatefromjpeg($resim_max);
break;
}
$this -> donen_resim_max = imagerotate($source_1, $aci, 0);
$this -> donen_resim_ad_max = $get;
if($this -> donen_resim_max || $this -> donen_resim_min || $this -> donen_resim_hd){
switch($type){
default:
imagejpeg($this -> donen_resim_max,$this -> donen_resim_ad_max,100);
break;
case "image/jpeg":
imagejpeg($this -> donen_resim_max,$this -> donen_resim_ad_max,100);
break;
}
return true;
} else {
return false;
}
}
public function simage_refresh($aci,$resim_hd,$resim_max,$resim_min){
$this -> donen_yeniAd = substr(uniqid(md5(rand())),0,40);
$this -> aci = $aci;
$degrees = $this -> aci;
$this -> donecek_resim_max = $resim_max;
$this -> donecek_resim_min = $resim_min;
$this -> donecek_resim_hd = $resim_hd;
$source_1 = imagecreatefromjpeg($this -> donecek_resim_max);
$source_2 = imagecreatefromjpeg($this -> donecek_resim_min);
$source_3 = imagecreatefromjpeg($this -> donecek_resim_hd);
$this -> donen_resim_max = imagerotate($source_1, $degrees, 0);
$this -> donen_resim_min = imagerotate($source_2, $degrees, 0);
$this -> donen_resim_hd = imagerotate($source_3, $degrees, 0);
$this -> donen_resim_ad_max = 'uploads/'.$dosya.'/'.$this -> yeniAd.'';
$this -> donen_resim_ad_min = 'uploads/'.$dosya.'/'.$this -> yeniAd.'';
$this -> donen_resim_ad_hd = 'uploads/'.$dosya.'/'.$this -> yeniAd.'';
if($this -> donen_resim_max || $this -> donen_resim_min || $this -> donen_resim_hd){
imagejpeg($this -> donen_resim_max,$this -> donen_resim_ad_max,100);
imagejpeg($this -> donen_resim_min,$this -> donen_resim_ad_min,100);
imagejpeg($this -> donen_resim_hd,$this -> donen_resim_ad_hd,100);
unlink($this -> donecek_resim_max);
unlink($this -> donecek_resim_min);
unlink($this -> donecek_resim_hd);
return true;
} else {
return false;
}
}
}
?>