|
|
@@ -30,6 +30,7 @@ class MediaService {
|
|
|
///
|
|
|
/// - [imageQuality] 图片质量(1-100),默认 90
|
|
|
/// - [maxWidth] 压缩后的最大宽度,默认 1080px
|
|
|
+ /// - [maxHeight] 压缩后的最大高度,默认 1920px
|
|
|
/// - [compressQuality] 压缩质量(1-100),默认 85
|
|
|
///
|
|
|
/// 返回压缩后的照片文件,如果用户取消或失败返回 null
|
|
|
@@ -38,6 +39,7 @@ class MediaService {
|
|
|
static Future<File?> pickFromCamera({
|
|
|
int imageQuality = PickerService.defaultImageQuality,
|
|
|
int maxWidth = ImageProcessor.defaultMaxWidth,
|
|
|
+ int? maxHeight,
|
|
|
int compressQuality = ImageProcessor.defaultQuality,
|
|
|
}) async {
|
|
|
try {
|
|
|
@@ -54,6 +56,7 @@ class MediaService {
|
|
|
final compressed = await ImageProcessor.compress(
|
|
|
file,
|
|
|
maxWidth: maxWidth,
|
|
|
+ maxHeight: maxHeight,
|
|
|
quality: compressQuality,
|
|
|
);
|
|
|
|
|
|
@@ -76,6 +79,7 @@ class MediaService {
|
|
|
///
|
|
|
/// - [imageQuality] 图片质量(1-100),默认 90
|
|
|
/// - [maxWidth] 压缩后的最大宽度,默认 1080px
|
|
|
+ /// - [maxHeight] 压缩后的最大高度,默认 1920px
|
|
|
/// - [compressQuality] 压缩质量(1-100),默认 85
|
|
|
///
|
|
|
/// 返回压缩后的图片文件,如果用户取消或失败返回 null
|
|
|
@@ -84,6 +88,7 @@ class MediaService {
|
|
|
static Future<File?> pickFromGallery({
|
|
|
int imageQuality = PickerService.defaultImageQuality,
|
|
|
int maxWidth = ImageProcessor.defaultMaxWidth,
|
|
|
+ int? maxHeight,
|
|
|
int compressQuality = ImageProcessor.defaultQuality,
|
|
|
}) async {
|
|
|
try {
|
|
|
@@ -100,6 +105,7 @@ class MediaService {
|
|
|
final compressed = await ImageProcessor.compress(
|
|
|
file,
|
|
|
maxWidth: maxWidth,
|
|
|
+ maxHeight: maxHeight,
|
|
|
quality: compressQuality,
|
|
|
);
|
|
|
|
|
|
@@ -120,6 +126,7 @@ class MediaService {
|
|
|
///
|
|
|
/// - [file] 原始图片文件
|
|
|
/// - [maxWidth] 最大宽度,默认 1080px
|
|
|
+ /// - [maxHeight] 最大高度,默认 1920px
|
|
|
/// - [quality] 压缩质量(1-100),默认 85
|
|
|
///
|
|
|
/// 返回压缩后的文件(覆盖原文件)
|
|
|
@@ -128,11 +135,13 @@ class MediaService {
|
|
|
static Future<File> compressImage(
|
|
|
File file, {
|
|
|
int maxWidth = ImageProcessor.defaultMaxWidth,
|
|
|
+ int? maxHeight,
|
|
|
int quality = ImageProcessor.defaultQuality,
|
|
|
}) async {
|
|
|
return await ImageProcessor.compress(
|
|
|
file,
|
|
|
maxWidth: maxWidth,
|
|
|
+ maxHeight: maxHeight,
|
|
|
quality: quality,
|
|
|
);
|
|
|
}
|