970_90

Tuesday, 25 November 2014

imagecopyresampled-Copy and resize part of an image with resampling

bool imagecopyresampled ( 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 )
Copy and resize part of an image with resampling
imagecopyresampled() copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.

<?php// The file

$filename 'test.jpg';
$percent 0.5;// Content type
header('Content-Type: image/jpeg');// Get new dimensions
list($width$height) = getimagesize($filename);$new_width $width $percent;$new_height $height $percent;// Resample
$image_p imagecreatetruecolor($new_width$new_height);
$image imagecreatefromjpeg($filename);
imagecopyresampled($image_p$image0000$new_width$new_height$width$height);// Output
imagejpeg($image_pnull100);?>


No comments:

Post a Comment