imagecreateresampled vs. imagecreateresized

If you are using image manipulation functions in PHP to resize a image, a common mistake is to use the imagecreateresized() function. Actually, most of the time, imagecreateresampled() function should be used.

According to the API document, imagecreateresampled()

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.

This brings the question that if imagecreateresampled() produce better image, why do we still need imagecreateresized() at all? My take on this is that the latter, although not creating as pretty image as the former one, executes much faster since less smoothing (anti-aliasing) is done during the process.

This entry was posted in PHP development. Bookmark the permalink.