阿里云图片裁剪 & 缩放
详细资料: https://help.aliyun.com/document_detail/44693.html
/* 阿里云图片裁剪*/
Baie.ImgClip = function(imgUrl, operate, options) {
var default_options = { /* 裁剪--设置默认参数值 */
w: 300,
h: 300,
x: 0,
y: 0,
g: 'nw'
}
if (operate == '/resize') { /* 缩放--设置默认参数值 */
default_options = {
w: 300,
h: 300,
m: 'fill'
}
}
var _options = extend(default_options, options),
_imgUrl = imgUrl,
_operate = operate,
type = 'x-oss-process=image',
urlArr = _imgUrl.split(type),
regexp = /@.*$/g;
_options = $.param(_options).replace(/&/g,',').replace(/=/g,'_');
if (urlArr.length == 1) {
if (urlArr[0].match(regexp)) {
urlArr[0] = urlArr[0].replace(regexp, '');
}
urlArr[0] = urlArr[0] + '?';
}
return urlArr[0] + type + _operate + ',' + _options;
}
裁剪参数说明
缩放参数说明
