压缩图片

This commit is contained in:
zhutao
2025-08-26 09:53:21 +08:00
parent abc438b74d
commit fafb6c010a
5 changed files with 78 additions and 26 deletions

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>497244455669-4c8jmohrsj81e7rpjfamv3kvr07haa6r.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.497244455669-4c8jmohrsj81e7rpjfamv3kvr07haa6r</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.curainhealth.derma</string>
</dict>
</plist>

View File

@@ -9,9 +9,13 @@ import 'package:dio/dio.dart';
import '../dto/article_dto.dart';
///皮肤检测
Future<SkinCheckDto> skinDetectApi(String path) async {
Future<SkinCheckDto> skinDetectApi(List<int> bytes) async {
FormData formData = FormData.fromMap({
"skin_image": await MultipartFile.fromFile(path),
"skin_image": MultipartFile.fromBytes(
bytes,
filename: "upload.jpg",
contentType: DioMediaType("image", "jpeg"),
),
});
var res = await Request().post("/skin/check", formData);
return SkinCheckDto.fromJson(res);
@@ -40,15 +44,15 @@ Future<RecordListDto> skinRecordApi({
}
///获取文章列表
Future<List<ArticleDto>> articleListApi() async{
var res = await Request().get("/customer-health/get_articles");
return (res['list'] as List).map((e) => ArticleDto.fromJson(e)).toList();
Future<List<ArticleDto>> articleListApi() async {
var res = await Request().get("/customer-health/get_articles");
return (res['list'] as List).map((e) => ArticleDto.fromJson(e)).toList();
}
///文章详情
Future<ArticleDetailDto> articleDetailApi(String id) async{
var res = await Request().get("/customer-health/get_article_detail", {
"id": id,
});
return ArticleDetailDto.fromJson(res);
Future<ArticleDetailDto> articleDetailApi(String id) async {
var res = await Request().get("/customer-health/get_article_detail", {
"id": id,
});
return ArticleDetailDto.fromJson(res);
}

View File

@@ -1,7 +1,10 @@
import 'dart:io';
import 'package:derma_flutter/router/config/route_paths.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
@@ -42,11 +45,21 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
///开始检测
void _startDetect(String path) async {
//压缩
final result = await FlutterImageCompress.compressWithFile(
path,
minWidth: 1080,
minHeight: 1920,
quality: 85,
rotate: 0,
);
print("压缩前:${File(path).lengthSync()}");
print("压缩后长度${result?.length}");
EasyLoading.show(
status: 'Skin analysis in progress, please wait...',
maskType: EasyLoadingMaskType.clear,
);
var res = await skinDetectApi(path);
var res = await skinDetectApi(result!);
EasyLoading.dismiss();
context.push(RoutePaths.detail, extra: res);
}

View File

@@ -174,6 +174,54 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.0"
flutter_image_compress:
dependency: "direct main"
description:
name: flutter_image_compress
sha256: "51d23be39efc2185e72e290042a0da41aed70b14ef97db362a6b5368d0523b27"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.4.0"
flutter_image_compress_common:
dependency: transitive
description:
name: flutter_image_compress_common
sha256: c5c5d50c15e97dd7dc72ff96bd7077b9f791932f2076c5c5b6c43f2c88607bfb
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.6"
flutter_image_compress_macos:
dependency: transitive
description:
name: flutter_image_compress_macos
sha256: "20019719b71b743aba0ef874ed29c50747461e5e8438980dfa5c2031898f7337"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
flutter_image_compress_ohos:
dependency: transitive
description:
name: flutter_image_compress_ohos
sha256: e76b92bbc830ee08f5b05962fc78a532011fcd2041f620b5400a593e96da3f51
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.3"
flutter_image_compress_platform_interface:
dependency: transitive
description:
name: flutter_image_compress_platform_interface
sha256: "579cb3947fd4309103afe6442a01ca01e1e6f93dc53bb4cbd090e8ce34a41889"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.5"
flutter_image_compress_web:
dependency: transitive
description:
name: flutter_image_compress_web
sha256: b9b141ac7c686a2ce7bb9a98176321e1182c9074650e47bb140741a44b6f5a96
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.5"
flutter_lints:
dependency: "direct dev"
description:

View File

@@ -27,6 +27,7 @@ dependencies:
image_picker: ^1.2.0
markdown_widget: ^2.3.2+8
sign_in_with_apple: ^7.0.1
flutter_image_compress: ^2.4.0
dev_dependencies: