Crop without resize

See all posts See thread Reply

Re: Crop without resize new!
by colin, 14 years, 7 months ago
You can do this indirectly: you can read image_src_x and image_src_y before calling process(), and act accordingly. For instance (not tested):
// the size you want
$my_x = 100;
$my_y = 100;
// the margins you will have to crop
$crop_x = (int) (($handle->image_src_x - $my_x) / 2);
$crop_y = (int) (($handle->image_src_y - $my_y) / 2);
// we set the cropping values
$handle->image_crop = array($crop_y, $crop_x, $crop_y, $crop_x);
// and call process()
$handle->process(...);
Reply