|
Yazan
|
Konu: resmi kesip resize etme (Okunma Sayısı 61 defa)
|
Nazgul2
Nazgul
PHP Stajyeri

Offline
Mesaj Sayısı: 158
Gentlemen, welcome to Fight Club
|
resmi keser istediğiniz boyuta getirir, saklar ve gösterir kaynak www.php.net<?php // Resmin Yeri | Nereye Kaydedilecek |Yeniboyutlar | renk resize_then_crop( 'images/pic1.jpg','images/filmler_k/ttt.jpg',151,124,/*rgb*/"255","255","255");
//Author Alan Reddan Silverarm Solutions //Date 27/01/2005 //Function that works well with images. //It takes the image and reduces its size to best fit. i.e If you have an image //that is 200 X 100 and you want a thumbnail of 75 X 50, //it first resizes the image to 100 X 50 //and then takes out a portion 75 X 50 from then center of the input image. //So loads of image information is retained. //The corollary also holds if your input image is 100 X 200 //it first resizes image to 75 X 150 and then takes out a //portion 75 X 75 from the centre // The advantage here is that function decides on whether //resize is by width or height itself. //it also decides whether to use the height or the width as the base start point //in the case that athumbnail is rectangular
function resize_then_crop( $filein,$fileout,$imagethumbsize_w,$imagethumbsize_h,$red,$green,$blue) {
// Get new dimensions list($width, $height) = getimagesize($filein); $new_width = $width * $percent; $new_height = $height * $percent;
if(preg_match("/.jpg/i", "$filein")) { $format = 'image/jpeg'; } if (preg_match("/.gif/i", "$filein")) { $format = 'image/gif'; } if(preg_match("/.png/i", "$filein")) { $format = 'image/png'; } switch($format) { case 'image/jpeg': $image = imagecreatefromjpeg($filein); break; case 'image/gif'; $image = imagecreatefromgif($filein); break; case 'image/png': $image = imagecreatefrompng($filein); break; }
$width = $imagethumbsize_w ; $height = $imagethumbsize_h ; list($width_orig, $height_orig) = getimagesize($filein);
if ($width_orig < $height_orig) { $height = ($imagethumbsize_w / $width_orig) * $height_orig; } else { $width = ($imagethumbsize_h / $height_orig) * $width_orig; }
if ($width < $imagethumbsize_w) //if the width is smaller than supplied thumbnail size { $width = $imagethumbsize_w; $height = ($imagethumbsize_w/ $width_orig) * $height_orig;; }
if ($height < $imagethumbsize_h) //if the height is smaller than supplied thumbnail size { $height = $imagethumbsize_h; $width = ($imagethumbsize_h / $height_orig) * $width_orig; }
$thumb = imagecreatetruecolor($width , $height); $bgcolor = imagecolorallocate($thumb, $red, $green, $blue); ImageFilledRectangle($thumb, 0, 0, $width, $height, $bgcolor); imagealphablending($thumb, true);
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $thumb2 = imagecreatetruecolor($imagethumbsize_w , $imagethumbsize_h); // true color for best quality $bgcolor = imagecolorallocate($thumb2, $red, $green, $blue); ImageFilledRectangle($thumb2, 0, 0, $imagethumbsize_w , $imagethumbsize_h , $white); imagealphablending($thumb2, true);
$w1 =($width/2) - ($imagethumbsize_w/2); $h1 = ($height/2) - ($imagethumbsize_h/2);
imagecopyresampled($thumb2, $thumb, 0,0, $w1, $h1, $imagethumbsize_w , $imagethumbsize_h ,$imagethumbsize_w, $imagethumbsize_h);
// Output //header('Content-type: image/gif'); //imagegif($thumb); //output to browser first image when testing
if ($fileout !="")imagejpeg($thumb2, $fileout); //gif yapmak için imagejpg header('Content-type: image/jpeg'); // gif yapmak için image/jpeg imagejpeg($thumb2); // gif yapmak için imagegif } ?>
|
|
|
|
|
Logged
|
1st&2nd: You do not talk about Fight Club! 3rd: If someone says "stop" or goes limp, taps out the fight is over. 4th: Only two guys to a fight. 5th: One fight at a time. 6th: No shirts, no shoes. 7th: Fights will go on as long as they have to 8th: If this is your first night, you have to fight.
|
|
|
|
 |