Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

压缩报错 #20

Open
309791679 opened this issue Apr 30, 2020 · 6 comments
Open

压缩报错 #20

309791679 opened this issue Apr 30, 2020 · 6 comments

Comments

@309791679
Copy link

CompressObject compressObject = CompressObject(
imageFile: File('/storage/emulated/0/fluttera/349.jpg'),
path: '/storage/emulated/0/fluttera/15882605447.jpg',
quality: 80,
step: 9,
mode: CompressMode.AUTO
);
var path =await (Luban.compressImage(compressObject));

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/fluttera/15882605447.jpg/img_1588261036457.jpg' (OS Error: No such file or directory, errno = 2)

用的最新版的flutter 和Dart ,图片是本地已经存在的,不知道为什么会提示找不到 报错

@309791679
Copy link
Author

I/flutter (13143):
E/flutter (13143): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/fluttera/15882605447.jpg/img_1588261790811.jpg' (OS Error: No such file or directory, errno = 2)
E/flutter (13143): #0 _File.throwIfError (dart:io/file_impl.dart:645:7)
E/flutter (13143): #1 _File.openSync (dart:io/file_impl.dart:489:5)
E/flutter (13143): #2 _File.writeAsBytesSync (dart:io/file_impl.dart:614:31)
E/flutter (13143): #3 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:213:12)
E/flutter (13143): #4 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #5 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #6 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #7 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #8 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #9 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #10 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #11 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #12 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #13 Luban._small2LargeCompressImage (package:flutter_luban/src/flutter_luban.dart:203:9)
E/flutter (13143): #14 Luban._lubanCompress (package:flutter_luban/src/flutter_luban.dart:145:9)
E/flutter (13143): #15 _IsolateConfiguration.apply (package:flutter/src/foundation/_isolates_io.dart:77:16)
E/flutter (13143): #16 _spawn. (package:flutter/src/foundation/_isolates_io.dart:84:45)
E/flutter (13143): #17 Timeline.timeSync (dart:developer/timeline.dart:163:22)
E/flutter (13143): #18 _spawn (package:flutter/src/foundation/_isolates_io.dart:82:18)
E/flutter (13143): #19 _startIsolate. (dart:isolate-patch/isolate_patch.dart:310:17)
E/flutter (13143): #20 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
E/flutter (13143):

@gonganruyi
Copy link

好像ios也会报错

@gonganruyi
Copy link

2021-02-21 22:43:43.968608+0800 Runner[622:41025] flutter: /private/var/mobile/Containers/Data/Application/B4A7A607-1366-4E04-8DA5-E0D4A3C82846/tmp/image_picker_FE272FA1-D43D-449B-AAEE-8FEAE5FC9719-622-0000002097230FF1.png
2021-02-21 22:43:46.406029+0800 Runner[622:40902] [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Exception: FormatException: Invalid Deflate parameter
#0 Deflate._init (package:archive/src/zlib/deflate.dart:95:7)
#1 new Deflate.buffer (package:archive/src/zlib/deflate.dart:36:5)
#2 ZLibEncoder.encode (package:archive/src/zlib_encoder.dart:40:32)
#3 PngEncoder.addFrame (package:image/src/formats/png_encoder.dart:45:36)
#4 PngEncoder.encodeImage (package:image/src/formats/png_encoder.dart:102:5)
#5 encodePng (package:image/src/formats/formats.dart:214:35)
#6 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:289:20)
#7 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#8 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#9 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#10 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#11 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#12 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#13 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#14 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#15 Luban._compressPng (package:flutter_luban/src/flutter_luban.dart:294:9)
#16 Luban._large2SmallCompressImage (package:flutter_luban/src/flutter_luban.dart:232:7)
#17 Luban._lubanCompress (package:flutter_luban/src/flutter_luban.dart:167:7)
#18 _IsolateConfiguration.apply (package:flutter/src/foundation/_isolates_io.dart:75:34)
#19 _spawn. (package:flutter/src/foundation/_isolates_io.dart:83:65)
#20 Timeline.timeSync (dart:developer/timeline.dart:163:22)
#21 _spawn (package:flutter/src/foundation/_isolates_io.dart:80:18)
#22 _startIsolate. (dart:isolate-patch/isolate_patch.dart:304:17)
#23 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

@au-top
Copy link

au-top commented Sep 23, 2021

确保有权限 可以试试 压缩存储在程序存放目录内的图片

在我这他工作的很好

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, 2.6.0-5.1.pre, on macOS 11.3.1 20E241 darwin-x64,
    locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
[✓] VS Code (version 1.60.1)
[✓] Connected device (3 available)

@adoontheway
Copy link

adoontheway commented Sep 29, 2022

我报的是 errno = 1

压缩图片: /Users/duke/Downloads/bg.jpg
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot open file, path = '/Users/duke/Downloads/img_1664423934143.jpg' (OS Error: Operation not permitted, errno = 1)

img_1664423934143.jpg 这个图片是不存在的,估计是压缩完后存放的文件名。
我是用的macos。

@adoontheway
Copy link

我报的是 errno = 1

压缩图片: /Users/duke/Downloads/bg.jpg
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot open file, path = '/Users/duke/Downloads/img_1664423934143.jpg' (OS Error: Operation not permitted, errno = 1)

img_1664423934143.jpg 这个图片是不存在的,估计是压缩完后存放的文件名。 我是用的macos。

这个问题已经解决了,由于我开发的是desktop,所以需要文件系统的权限,
在macos中找到文件:DebugProfile.entitlements
将配置部分改为如下即可:

<key>com.apple.security.app-sandbox</key>
	<false/>
	<key>com.apple.security.cs.allow-jit</key>
	<true/>
	<key>com.apple.security.network.server</key>
	<true/>

	<key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-only</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants