Monday, June 15, 2009

Cropping in PHP

When an image is uploaded, Complete image will be displayed, But there may be a situation where we need to have only part of the image to be displayed instead of complete image. So in that scenario's we use the concept called CROPPING.
The croppping option is the apt solution for such type of queries. This provides with same many options to the user. User can easily select the area, Which area he wants to crop. By providing the options user feels free to use the website.

The below downloading code is the basic version of the cropping. The downloading folder will contain the 2 folder and 2 files.

1. JS folder which contains the javascript function needed for the cropping option.
2. upload_pic which contains the uploaded images and the cropped images. When the
images are cropped, Then the images are saved in this folder.
3. Cropping document.txt which contains all the data related to the cropping like
where to change the width and height of the cropped area, where the files are
saving etc.
4. upload_crop.php contains the php code.

Code Explanation:

resizeThumbnailImage() This function is used to save the cropped image,It takes the thumb image name , height , width, starting height,starting width, scale .

getWidth,getHeight These methods are used for getting the uploaded image width and the height.

0 comments:

Post a Comment