// 按照边长缩放
import 'package:yp_erp/Common/Util/image_url_util.dart';
String resizeImageUrlWithLength(String url, int length) {
if (!url.contains('?')) {
return url + '?x-oss-process=image/resize,l_$length';
} else {
return url + 'x-oss-process=image/resize,l_$length';
}
}
// 按照高缩放 缩放模式为lfit:m_lfit
String resizeImageUrlWithHeight(String url, int height) {
if (!url.contains('?')) {
return url + '?x-oss-process=image/resize,h_$height,m_lfit';
} else {
return url + 'x-oss-process=image/resize,h_$height,m_lfit';
}
}
// 按照宽高缩放 缩放模式fixed:m_fixed (固定宽高缩放)
String resizeImageUrlWithHW(String url, int height, int width) {
if (!url.contains('?')) {
return url + '?x-oss-process=image/resize,m_fixed,h_$height,w_$width';
} else {
return url + 'x-oss-process=image/resize,m_fixed,h_$height,w_$width';
}
}
// 按照宽高缩放 缩放模式fill:m_fill(固定宽高,自动裁剪)
String resizeImageUrlFill(String url, int height, int width) {
// 过滤不规范的url
String foomatUrl = ImageUrlUtil.formatUrl(url);
if (!foomatUrl.contains('?')) {
return foomatUrl + '?x-oss-process=image/resize,m_fill,h_$height,w_$width';
} else if (foomatUrl.contains('x-oss-process')) {
return foomatUrl;
} else {
return foomatUrl + 'x-oss-process=image/resize,m_fill,h_$height,w_$width';
}
}
// 按比例缩放
String resizeImageUrProportion(String url, int p) {
if (!url.contains('?')) {
return url + '?x-oss-process=image/resize,p_$p';
} else {
return url + 'x-oss-process=image/resize,p_$p';
}
}
// 固定宽高 缩放填充 缩放模式pad:m_pad,colorS 为填充色(例:FFFFFF)
String resizeImageFixdWH(
String url, int heigth, int width, int p, String colorS) {
if (!url.contains('?')) {
return url +
'?x-oss-process=image/resize,m_pad,h_$heigth,w_$width,color_$colorS';
} else {
return url +
'x-oss-process=image/resize,,m_pad,h_$heigth,w_$width,color_$colorS';
}
}
网友评论