Crop

You can crop an image by passing in four coordinates: left, top, width, height to the crop() method. The result is an image cropped to the specified rectangle. You can use smart coordinates for the parameters value.

Crop a 100×50 rectangle from the top-left corner:

  1. $cropped = $image->crop(0, 0, 100, 50);

Crop a 200×250 rectangle from the exact center of the image (using smart coordinates):

  1. $cropped = $image->crop('50%-100', '50%-125', 200, 250);
  2. $cropped = $image->crop('center', 'center', 200, 250);

Crop a 100×20 rectangle from the bottom-right corner of the image, with a 10px margin:

  1. $cropped = $image->crop('100%-110', '100%-30', 100, 20);
  2. $cropped = $image->crop('right – 10', 'bottom – 10', 100, 20);

See the crop demo.

Note: WideImage can also auto-crop images. See autoCrop demo and documentation.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Tumblr
  • Twitter