Hello.
It's my first time using the function ImageCopyResampled. I just followed the code written in the PHP manual. There seemed to be no errors when I ran the code. The problem is my code just basically copies the original image and did not follow the dimensions as it was defined in the parameters passed in the function. Below is my code:
public static function uploadFile($filename, $x_dimension, $y_dimension, $width, $height){
$file = DOCROOT . "uploads/temp/".$filename;
$trgt_file = DOCROOT . "uploads/images/thumbs/".$filename;
if(is_file($file) AND file_exists($file)):
$trgt_w = 198;
$trgt_h = 130;
if(copy($file, $trgt_file)):
$src_img = imageCreateFromJpeg($file);
$trgt_img = imageCreateTrueColor($trgt_w, $trgt_h);
imageCopyResampled($trgt_img, $src_img, 0, 0, $x_dimension, $y_dimension, $trgt_w, $trgt_h, $width ,$height);
unlink($file);
endif;
endif;
}
This function just copy the source file and no cropping happened. What did I miss?
BTW, Im using kohana 3. Thanks.