GithubHelp home page GithubHelp logo

Comments (4)

vanniktech avatar vanniktech commented on June 5, 2024

I think it is, but if you pass the URI yourself you can manage it yourself. This is also what I'm doing. The current tmp automatic creation is a relict which I haven't cleaned up yet.

from android-image-cropper.

LaurentLixfe avatar LaurentLixfe commented on June 5, 2024

Hello, you should parse your cache directory too. Find any "tmp_image*" or "cropped*" file name and delete it at the end of your flows.

from android-image-cropper.

einhazard avatar einhazard commented on June 5, 2024

Thanks, everyone, appreciate the suggestion

Based on @vanniktech suggestion to pass URI, I think I got what I wanted cleaner than deleting the file each time, but I don't know if this will be a problem in the future, I hope you guys can give me your comment

What I changed from your sample is instead of using createTempFile, I made the file using standard File

outputUri = null
private fun createImageFile(): File {
    val fileName = "${Koneksi.FP_FILE_NAME}${Koneksi.FP_FILE_FORMAT}"
    val storageDir: File? = myActivity.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
    val file = File(storageDir, fileName)

    val absolutePath = file.absolutePath
    Log.e("HK", "createImageFile path = $absolutePath")

    return file
}

And at CropImageContractOptions, I added outputUri on both uri and customOutputUri

cropImage.launch(
        CropImageContractOptions(
            uri = outputUri,
            cropImageOptions = CropImageOptions(
                imageSourceIncludeGallery = false,
                imageSourceIncludeCamera = true,
                guidelines = CropImageView.Guidelines.ON,
                outputCompressFormat = Bitmap.CompressFormat.JPEG,
                outputCompressQuality = 85,
                fixAspectRatio = true,
                aspectRatioX = 1,
                aspectRatioY = 1,
                customOutputUri = outputUri
                )
            ,
        ),
    )

everything else is still the same as the sample, and using the above code I made the app only make 1 file with the exact name that will be overwritten every time user does the cropping, so no additional code to delete the file needed

image

from android-image-cropper.

vanniktech avatar vanniktech commented on June 5, 2024

Yep that is also what I do

from android-image-cropper.

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.