lib/url/imageurl.js
function(options) {
        var opts = options || {},
            mode = opts.mode,
            x = opts.x,
            y = opts.y,
            width = opts.width,
            height = opts.height;

        if (!mode && (isNaN(x) || isNaN(y))) {
            throw new Error('x and y needs to be specified without a crop mode');
        }

        if (mode === 'center-x' && isNaN(y)) {
            throw new Error('y needs to be specified when mode is center-x');
        } else if (mode === 'center-y' && isNaN(x)) {
            throw new Error('x needs to be specified when mode is center-y');
        } else if (isNaN(width) || isNaN(height)) {
            throw new Error('width and height needs to be specified');
        }

        var params = [
            'width=' + toInt(width),
            'height=' + toInt(height)
        ];

        if (isNumeric(x)) {
            params.push('x=' + toInt(x));
        }

        if (isNumeric(y)) {
            params.push('y=' + toInt(y));
        }

        if (mode) {
            params.push('mode=' + mode);
        }

        return this.append('crop:' + params.join(','));
    }
function(options) {
        var opts = options || {},
            mode = opts.mode,
            x = opts.x,
            y = opts.y,
            width = opts.width,
            height = opts.height;

        if (!mode && (isNaN(x) || isNaN(y))) {
            throw new Error('x and y needs to be specified without a crop mode');
        }

        if (mode === 'center-x' && isNaN(y)) {
            throw new Error('y needs to be specified when mode is center-x');
        } else if (mode === 'center-y' && isNaN(x)) {
            throw new Error('x needs to be specified when mode is center-y');
        } else if (isNaN(width) || isNaN(height)) {
            throw new Error('width and height needs to be specified');
        }

        var params = [
            'width=' + toInt(width),
            'height=' + toInt(height)
        ];

        if (isNumeric(x)) {
            params.push('x=' + toInt(x));
        }

        if (isNumeric(y)) {
            params.push('y=' + toInt(y));
        }

        if (mode) {
            params.push('mode=' + mode);
        }

        return this.append('crop:' + params.join(','));
    }
function ( options ) { var opts = options || { } , mode = opts . mode , x = opts . x , y = opts . y , width = opts . width , height = opts . height ; if ( ! mode && ( isNaN ( x ) || isNaN ( y ) ) ) { throw new Error ( 'x and y needs to be specified without a crop mode' ) ; } if ( mode === 'center-x' && isNaN ( y ) ) { throw new Error ( 'y needs to be specified when mode is center-x' ) ; } else if ( mode === 'center-y' && isNaN ( x ) ) { throw new Error ( 'x needs to be specified when mode is center-y' ) ; } else if ( isNaN ( width ) || isNaN ( height ) ) { throw new Error ( 'width and height needs to be specified' ) ; } var params = [ 'width=' + toInt ( width ) , 'height=' + toInt ( height ) ] ; if ( isNumeric ( x ) ) { params . push ( 'x=' + toInt ( x ) ) ; } if ( isNumeric ( y ) ) { params . push ( 'y=' + toInt ( y ) ) ; } if ( mode ) { params . push ( 'mode=' + mode ) ; } return this . append ( 'crop:' + params . join ( ',' ) ) ; }
Crops the image using specified parameters

@param  {Object} options
@param  {String} [options.mode] Crop mode: "center-x" or "center-y" (available in Imbo >= 1.1.0)
@param  {Number} [options.x]    X coordinate of the top left corner of the crop
@param  {Number} [options.y]    Y coordinate of the top left corner of the crop
@param  {Number} options.width  Width of the crop
@param  {Number} options.height Height of the crop
@return {Imbo.ImageUrl}
Crops the image using specified parameters