Saturday, 30 April 2016

imagecopyresized PHP GD Function

Copy and resized the specific part of an image

Syntax:

bool imagecopyresized ( 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 )

Argument Detail:

dst_image
Destination image link resource.

src_image
Source image link resource.

dst_x
x-coordinate of destination point.

dst_y
y-coordinate of destination point.

src_x
x-coordinate of source point.

src_y
y-coordinate of source point.

dst_w
Destination width.

dst_h
Destination height.

src_w
Source width.

src_h
Source height.

example:

list($width, $height) = getimagesize($_FILES['file']['tmp_name']);
$thumb = imagecreatetruecolor(300, 200); //Add your custom image size
$source = imagecreatefromjpeg($_FILES['file']['tmp_name']);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, 300, 200, $width, $height);

No comments:

Post a Comment