Zihni Özgürlük

Arama Sonuçları ‘imagecopyresized’

imagecopyresized() Fonksiyonu

Sözdizimi:

1
bool <strong><strong>imagecopyresized</strong></strong> ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )

Resim dosyasını yeniden boyutlandırır ve kopyasını oluşturur.

Örnek:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$fileName = "test.jpg";
$newName = "test1.jpg";
 
$percent = 0.5;
list($width, $height) = getimagesize($fileName);
header("Content-type: image/jpeg");
 
// %50 oranında küçültülmüş yeni boyutları ayarlıyoruz.
$newHeight = $height * $percent;
$newWidth = $width * $percent;
 
 
$thumb = imagecreatetruecolor($newWidth,$newHeight);
$source = imagecreatefromjpeg($fileName);
 
// yeniden boyutlandırıyoruz
imagecopyresized($thumb,$source,0,0,0,0,$newWidth,$newHeight,$width,$height);
 
//ekrana yazdırıyoruz
imagejpeg($thumb);