Craft\ImageResizerController::actionCropSaveAction PHP Method

actionCropSaveAction() public method

    public function actionCropSaveAction()
    {
        $this->requireAjaxRequest();
        try {
            $x1 = craft()->request->getRequiredPost('x1');
            $x2 = craft()->request->getRequiredPost('x2');
            $y1 = craft()->request->getRequiredPost('y1');
            $y2 = craft()->request->getRequiredPost('y2');
            $source = craft()->request->getRequiredPost('source');
            $assetId = craft()->request->getPost('assetId');
            // We're editing an existing image
            if ($assetId) {
                $asset = craft()->assets->getFileById($assetId);
                $result = craft()->imageResizer_crop->crop($asset, $x1, $x2, $y1, $y2);
                if ($result) {
                    $this->returnJson(array('success' => true));
                } else {
                    $this->returnErrorJson(Craft::t('Could not crop the image.'));
                }
            }
        } catch (Exception $exception) {
            $this->returnErrorJson($exception->getMessage());
        }
        $this->returnErrorJson(Craft::t('Something went wrong when processing the image.'));
    }