Closed einhazard closed 5 months ago
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.
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.
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
Yep that is also what I do
Sorry if I'm wrong, but is tmp_image_file created from your function too?
I don't want to save any cache file, I can delete cropped file after I use using code like this
but I can't find any of your function that make tmp_image_file. Where can I find it?