PHP Classes

Crop Canvas: A class to crop images in a variety of ways.

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (5)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2006-11-29 (8 years ago) RSS 2.0 feedStarStarStarStar 65%Total: 4,915 All time: 508 This week: 1,209Down
Version License Categories  
crop-canvas 1.0Free for non-comm...Graphics
Description Author  

This is a class allows you to crop an image in a variety of ways.

You can crop in an absolute or relative way (to a certain size or by a certain size), both as a pixel number or a percentage.

You can also save or display the cropped image.

The cropping can be done in 9 different positions: top left, top, top right, left, centre, right, bottom left, bottom, or bottom right.

Or you can have it automatically cropped based on a threshold value.

The original image can be loaded from the file system or from a string (for example, data returned from a database.)

It will also compensate so you can use GD versions 1.x or 2.x (though obviously 2.x will produce much better results!)

Picture of Andrew Collington
Name: Andrew Collington <contact>
Classes: 13 packages by
Country: United Kingdom United Kingdom
Age: 41
All time rank: 524 in United Kingdom United Kingdom
Week rank: 1641 Down68 in United Kingdom United Kingdom Down

  Files folder image Files  
File Role Description
Plain text file class.cropcanvas.php Class The main class file.
Plain text file class.cropinterface.php Class A web-based interface to the crop canvas class.
Accessible without login Plain text file inc.cropimage.php Aux. Dynamically outputs a resized image.
Accessible without login Plain text file inc.cropinterface.php Aux. The client-side code for the cropping interface.
Accessible without login Plain text file inc.cropjavascript.php Aux. Initiates elements to be handled by javascript.
Accessible without login Plain text file test.cropcanvas.php Example Just to show a few ways the class can be used.
Accessible without login Plain text file test.cropinterface.php Example Demo of cropping interface
Accessible without login Plain text file wz_dragdrop.js Aux. The drag & drop javascript behind the cropping interface. This code is created by Walter Zorn (

 Version Control Unique User Downloads Download Rankings  
 0%Total:4,915All time:508
 This week:0This week:1,209Down
User Ratings User Comments (4)  
 All time
This script is one of the best scripts for image cropping fro...
4 years ago (Iftikhar Mirza)
Really, really great.
5 years ago (pablo)
Just what I wanted, saved me the Job, thanks!!
6 years ago (Piet Hermans)
Very useful
7 years ago (Nguyen Duc Phu)