压缩图片
This commit is contained in:
@@ -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>
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
48
pubspec.lock
48
pubspec.lock
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user