ryancramerdesign/ProcessWire — pull request #533 by horst-n (2014-06-22 14:29:21+00:00)
Title: added "crop _before_ resize" functionality

this is to allow third party modules like Thumbnails to delegate their complete image manipulation to ImageSizer, - or to any dropped in PageimageSizerModule!

It is not intended to call this manually.

@Ryan: I have tested this with Thumbnails module and it works well. But just for quick testing, the following code can be executed in a template:

$image = $page->images->first();
$image->removeVariations();
$x = 50;
$y = 150;
$w = intval(($image->width - $x) / 2);
$h = intval(($image->height - $y) / 2);
$options = array('cropExtra'=>array('x'=>$x, 'w'=>$w, 'y'=>$y, 'h'=>$h));
$img = $image->size(intval($w * 0.8), intval($h * 0.8), $options);
echo "<img src='{$img->url}' /> $img->name";