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

Simply doesn't work #10

Open
jifferon opened this issue Jan 31, 2019 · 1 comment
Open

Simply doesn't work #10

jifferon opened this issue Jan 31, 2019 · 1 comment

Comments

@jifferon
Copy link

Here's a module for compressor

@Module
class CompressorModule {
    @Provides
    @Singleton
    fun provideCompressor(context: Context) = Resizer(context)
            .setTargetLength(1000)
            .setQuality(75)
            .setOutputFormat("JPEG")
            .setOutputFilename(UUID.randomUUID().toString())
            .setOutputDirPath(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)!!.absolutePath)
}

And here's how we use it:

 override fun uploadImage(file: File): Single<Image> =
            file.run {
                System.out.println("Pre compressor size: ${file.totalSpace}")
                resizer
                        .setSourceImage(file)
                        .resizedFileAsFlowable
                        .subscribeOn(Schedulers.io())
                        .singleOrError()
                        .flatMap { compressedFile ->
                            System.out.println("Post compressor size: ${compressedFile.totalSpace}")
                            Single.fromCallable {
                                defaultApi.v2ImagesPost(compressedFile)
                            }
                        }
            }

And here's result of compression:

I/System.out: Pre compressor size: 57986539520
I/System.out: Post compressor size: 57986539520

Thus, nothing has changed: not size, not file resolution (which is twice the size specified). What are we doing wrong?

@jifferon
Copy link
Author

My bad, my way of determination of file size was totally wrong. Still, image dimensions won't change

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

1 participant