// alt iki satırda dosyayı belirliyor be onu % kaç resize edicemiyi yazıoz.
$filename = "dene.jpg";
$percent = 0.5;
header("Content-type: image/jpeg");
// ve seçilen yüzdelik(percent) ile yeni boyutlarımızı oluşturuyoz.
list($width, $height) = getimagesize($filename);
$newwidth = 180;
$newheight = 160;
// artık kaynağı yeni boyutları ile harmanladık.
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// resim bu bölümde son halini yani yeni boyutlarını aldı
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// ve dosyayı istenen % olarak kalite ile istenen adrese kaydettik
imagejpeg($thumb, "dene.jpg", 100);
?>
emrah ülker
emrah@planesoft.net
Programlama > PHP
Resim crop lama
İşinize yaramı bilmem ama çok sağlam çünkü kalite bozmadan resim croplamak için
Hepsini Seç
$imgfile = "img.jpg";
$cropStartX = 300;
$cropStartY = 250;
$cropW = 200;
$cropH = 200;
$origimg = imagecreatefromjpeg($imgfile);
$cropimg = imagecreatetruecolor($cropW,$cropH);
list($width, $height) = getimagesize($imgfile);
imagecopyresized($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height);
header("Content-type: image/jpeg");
imagejpeg($cropimg);
imagedestroy($cropimg);
imagedestroy($origimg);
?>
Comments (0) | Add Comment
