ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.16k stars 1.56k forks source link

android openCamera auto save to gallery #863

Open ahyong87 opened 6 years ago

ahyong87 commented 6 years ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

Expected behaviour

Actual behaviour

Steps to reproduce

  1. android take photo, image will auto save to Gallery Gallery image path "file:///storage/emulated/0/Pictures/image-2010b3a6-b74d-420c-baea-de8390da184a71335456.jpg"

App path "file:///data/user/0/com.vaneijck/cache/react-native-image-crop-picker/90e9e92f-faf6-463b-98b7-f5a0da5aae99.jpg"

  1. try ImagePicker.clean also not work

Attachments

// stacktrace or any other useful debug info

Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate

jamesaharvey commented 5 years ago

I'm having this same issue. I do not want the image to persist on the Android device's gallery. I only want the base64 string which, in my case, I send to a server and after that I am done with the camera/gallery and don't want any remnants left on the device.

winardis commented 5 years ago

I'm also facing this issue when i use the picker with multiple images it doesn't save any of the images that user selected, but on other case where I only need to pick 1 image with cropping enabled, it saves that image to "storage/emulated/0/Pictures" Note: I have also tried using "ImagePicker.clean()" but the results remain the same"

vemulanishanth commented 5 years ago

This issue will clog the mobile storage with unwanted junk images. Is there no way to stop this from happening?

adrianomarquess commented 5 years ago

Any solution to this?

vemulanishanth commented 5 years ago

LAZIEST SOLUTION I CAN THINK OF: You guys are generating random name for both original and compressed image atleast generate once for original image and add "_compressed" or expose a property for end user to choose the suffix string for the compressed image so that the same end user can take care of the issue.

ows-ali commented 4 years ago

Anybody found any solution to this? @vemulanishanth how do we set names for original and cropped images in android?

salvariable commented 4 years ago

I know react-native-camera' doNotSave prop solves this, does anybody know if it could be inherited in this lib?

sataporn8063 commented 3 years ago

try update to "react-native-image-crop-picker": "^0.36.0" and in android/build.gradle update to this version classpath("com.android.tools.build:gradle:3.5.4")

alejandrosazo commented 3 years ago

Any solution?, I have the same problem

alejandrosazo commented 3 years ago

Ok ... I have a quick fix. The "react-native-fs" library contains a method for deleting files.

So we create a function with the following code:

const DeleteFile = (path) => { RNFS.unlink(path) }

Then we call the function within the method that performs the capture / selection of the image:

const takePickSingleWithCamera = (cropping, mediaType = 'photo') => { ImagePicker.openCamera({ cropping: cropping, width: 500, height: 500, includeBase64: true, includeExif: true, mediaType, }) .then((image) => { setCameraPick(image.data) DeleteFile(image.path) }) .catch((e) =>Alert.alert(e)); }`

The instant the photo is uploaded and the Base64 is obtained, the image will be removed from the directory. It is useful if our objective is only Base64 and to avoid storing unnecessary images.

My Versions: "react": "16.13.1", "react-native": "0.63.4", "react-native-image-crop-picker": "^0.35.1", "react-native-fs": "^2.17.0"

vemulanishanth commented 3 years ago

@alejandrosazo I don't think you get the issue here. I do not know if the issue is still present right now.

But when I faced the issue, I clearly remember the workflow to reproduce it.

  1. Perform the capture operation with compression
  2. package takes the original image. Compresses and creates a new image (name generated by random uuid generator).
  3. Original image is stored in the Pictures folder but you do not have the path to delete yourself nor the package delete it.
  4. You have the path to the compressed image. Do whatever you want with it. Delete it after it's no longer useful using the RNFS or anything.

after digging through the commits you find in the following links that the original image is not being deleted after the compressed/resized image is created

https://github.com/ivpusic/react-native-image-crop-picker/blob/f12326b59c4387ecfebcb7283bb85db975dc4498/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java

https://github.com/ivpusic/react-native-image-crop-picker/blob/f12326b59c4387ecfebcb7283bb85db975dc4498/android/src/main/java/com/reactnative/ivpusic/imagepicker/Compression.java