Saturday 30 April 2016

Resized and Saved Uploaded Image in PHP

Image resizing is an important task because if uploaded image size is bigger than requirement and we are not resizing it then it will consume server space and bandwidth which is not good.
So Resizing is necessary .you need to use four PHP GD functions for achieve this.

imagejpeg PHP GD Function

Creates and output an image to browser or saved into a file

Syntax:

bool imagejpeg ( resource $image [, string $filename [, int $quality ]] )

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 )

imagecreatefromjpeg PHP GD Function

Create a new image from a url or uploaded by file control

syntax:

resource imagecreatefromjpeg ( string $filename )

Argument Detail:

filename Path to the JPEG image.

Return Values :