Equity Release - Buy Shares - Loans - Loans - Credit Cards UK

PDA

View Full Version : how to use imagecopyresampled correctly


figo2476
Apr 5th 2008, 12:36 am
I have an image and I want to crop portion of the original image.

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 )

I pass the cropped image size & original image size to the function. The end result is that a smaller image with black spacing around the bottom and right side. Then the original image (it resize itself ugly) to the rest of the area.

But if the dst and src are in the same width and height, the end result has no problem. Any hint?

blognol
Apr 5th 2008, 4:14 am
Hi,

Have you create "imagecreatetruecolor" before "imagecopyresampled". For example see the below code
$src_image = @imagecreatefromgif($imagepath);
$dest_image = @imagecreatetruecolor ($output_width, $output_height);
imagecopyresampled($dest_image, $src_image, 0, 0, 0, 0, $output_width, $output_height, $imgwidth, $imgheight);
imagegif($dest_image, $imagepath, 100);