Coder Social home page Coder Social logo

Comments (10)

forJrking avatar forJrking commented on May 27, 2024

如下

        val arrays = ArrayList<File>()
        Luban.with(this)                         //Lifecycle 获取,可以不填写参数也可使用ProcessLifecycleOwner
                .load(arrays)                          //_**支持 File,Uri,InputStream,String,和以上数据数组和集合**_
                .setOutPutDir(path)                      //输出目录文件夹
                .concurrent(true)          //多文件压缩是否并行,内部优化并行数量防止OOM
                .useDownSample(true)    //压缩算法 true采用邻近采样,否则使用双线性采样(纯文字图片效果绝佳)
                .format(Bitmap.CompressFormat.PNG)      //压缩后输出文件格式 支持 JPG,PNG,WEBP
                .ignoreBy(200)                     //期望大小,大小和图片呈现质量不能均衡所以压缩后不一定小于此值,
                .quality(95)                     //质量压缩系数  0-100
                .rename { "pic$it" }                    //文件重命名
                .filter { true }                        // 过滤器
                .compressObserver {
                    onSuccess = { }
                    onStart = {}
                    onCompletion = {}
                    onError = { e, s -> }
                }.launch()

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024
    val arrays = ArrayList<File>()

数组是 string类型的文件路径 是否可以?

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024

因为我使用的时候传入string类型的文件路径 list,报错,

from kluban.

forJrking avatar forJrking commented on May 27, 2024

File,Uri,InputStream,String,和以上数据 单个、数组、集合 都支持的 具体报错显示什么错误

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024

2021-04-01 15:01:28.625 9306-9306/com.pinet.cloth.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pinet.cloth.android, PID: 9306
java.io.IOException: Incoming data type exception, it must be String, File, Uri
at d.l.a.c$b.e(Luban.kt:107)
at d.l.a.f.a.a(InputStreamAdapter.kt:26)
at com.forjrking.lubankt.Builder$compress$2.invokeSuspend(Luban.kt:253)
at com.forjrking.lubankt.Builder$compress$2.invoke(Unknown Source:10)
at g.a.h3.b.e(Undispatched.kt:91)
at g.a.h.e(Builders.common.kt:160)
at g.a.f.g(Unknown Source:1)
at com.forjrking.lubankt.Builder.f(Luban.kt:247)
at com.forjrking.lubankt.MultiRequestBuild$asyncRun$1$invokeSuspend$$inlined$map$1$2$lambda$1.invokeSuspend(Luban.kt:346)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at g.a.t0.run(DispatchedTask.kt:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
at d.l.a.b$b.run(Luban.kt:390)

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024

我传入的是string 类型的图片路径 list ,路径上传到阿里云是可以的

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024

暂时是模拟器测试的。
/storage/emulated/0/DCIM/com.pinet.cloth.android/1617246751183_100.JPG

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024
val compileSdkVersion = 30
val buildToolsVersion = "30.0.2"
val minSdkVersion = 23
val targetSdkVersion = 30

from kluban.

forJrking avatar forJrking commented on May 27, 2024

原因找到了,我的问题。先按下面这样写

       val arrays = ArrayList<String>()
        Luban.with(this)                     
                .load(*arrays.toArray())         

from kluban.

RookieExaminer avatar RookieExaminer commented on May 27, 2024

可以用了,感谢

from kluban.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.