Snippets - Resize and crop

Snippets index page

NOTE: Most of the IM snippets have been tested on IM version 6.3.5 There may be some differences if you are using the code on other versions.

Crop an image - Anthony 20/6/2008

Crop part of an image.240x180+100+100 = Crop to be 240 wide by 180 high and crop top left hand corner to be 100 across and 100 down.

  1. <?php
  2. exec("convert input.jpg -crop 240x180+100+100 +repage output.png");
  3. ?> 

For more examples and information check out the main Imagemagick section.

Clone View

Crop an image View

Crop an image into pieces View

Dividing an image View

Keep minimum image size View

New image size in variable View

Resize if over certain size View

Resize keep aspect ratio. View

Resize no aspect ratio. View

Speed up jpg resize View