ImageCopyResized and ImageCopyResampled

This tutorial covers resizing or resampling of images with PHP GD. The differences between the 2 are:

imagecopyresized will copy and scale an image. This uses a fairly premitive algorithm that tends to yield more pixelated results

imagecopyresampled will copy and scale an image, it uses a smoothing and pixel interpolating algorithm that will generally yield much better results than imagecopyresized at the cost of a little cpu usage. They both use the same algorithm.

imagecopyresized($dest_img, $src_img, $dest_x, $dest_y, $src_x, $src_y, $dest_w, $dest_h, $src_w, $src_h);


The images above were resized from this image. They are half size, using the script to the right (only changing from imagecopyresized to imagecopyresample). There is no real visible difference in this example. The images below, cut out a piece of the image and resized it. Right click, select all, ctrl+c to copy.


imagecopyresized($dst, $src, 0, 0, 150, 0, 200, 200, 90, 200);

This line in the sample script says to cut the flower image (src) starting at 150,0, (now 150 becomes 0), then cut it at 90,200 (w,h), from that starting point. The background (dst) image is 0,0, to 200,200 which is the size of the final image.
Right click, select all, ctrl+c to copy.
This is an interesting script that uses a loop and resample to create a perspective from an image
Right click, select all, ctrl+c to copy.

Flip Vertical

Flip Horizontal
This is a script that uses imagecopyresampled to flip or flop an image (or both).FlipFlop zip
A script by DJ Mike to make a cylinder, using resample.