PHP Classes

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

Recommend this page to a friend!
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (6)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 65%Total: 4,950 All time: 546 This week: 73Up
Version License Categories
crop-canvas 1.0Free for non-comm...Graphics


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
  Performance   Level  
Name: Andrew Collington <contact>
Classes: 16 packages by
Country: United Kingdom
Age: 50
All time rank: 563 in United Kingdom
Week rank: 328 Down11 in United Kingdom Down
Innovation award
Innovation award
Nominee: 3x

  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  
This week:0
All time:546
This week:73Up
User Ratings User Comments (4)
 All time
This script is one of the best scripts for image cropping fro...
13 years ago (Iftikhar Mirza)
Really, really great.
14 years ago (pablo)
Just what I wanted, saved me the Job, thanks!!
15 years ago (Piet Hermans)
Very useful
16 years ago (Nguyen Duc Phu)