capture camera image but not save a file - android

Is it possible to capture a camera image and use it in my code, but not have the image saved on the device? I need the image for sending to an API, but I have no need for the user to have the file afterwards. Can this be done?

This is not a good idea, as there is too much overhead when handling the full size image in RAM.
I would personally just create a scaled down preview to put in UI(if needed), then upload original(saved on SD) image and delete afterwards.
Some devices will force the images into the gallery.
This will help you with said problem
Here is my edited answer in regard to how i would do it.
Save image to disk and ensure it is encoded correctly for the API you are using.
Start upload service when network connection is available (if necessary).
Either delete image from service or schedule an Alarm to start service and deal with it later

if u r using native camera activity
capture the image on file
get the bitmap of the image from the file
delete the file
(u can save the image in hidden directory {{its name should start with dot .hidden_dir/myimg.jpg }} )

Related

How do I avoid saving captured image in my device?

I have to create functionality for an application where I have to take pictures and save it to a SQLite database. I have implemented the camera for now using the camera intent in android, but the image gets saved to the gallery. I have read the Camer2 and CamerX API documentation and the image still gets saved to a device folder. Is there any way to avoid this?
You can checkout https://stackoverflow.com/a/64651558/277368 on how to get in-memory image with CameraX. Then you need to serialize the image and save it to SQLite on your own.

Cordova camera changes filename after saving to gallery on iOS

i am using the cordova camera plugin and saving images to the gallery/photos so they don't delete as prior to this my photos would be saved to the cache and delete quickly enough.
I attach the images i take and save with camera plugin to an email.
What i do is save the ImageURI from the camera function to localstorage to be called again if i resend the email at a later date.
This method works in the short-term and images attach successfully but not after a few hours.
The imageURI of captured images is usually on the format of cdv_photo_001.jpg for example.
However, the images are saved in photos/gallery and the filenames tend to be normal "IMG_0001.JPG" format and don't attach to the email.
is there a way i can get the actual gallery name while taking a picture.
Ive tried to save the image persistently using some guides but i could never get the moveTo to work.
Anyone any ideas?
Thanks

Why do I need to create a file on disk to get a full size image taken by the camera

I'm working with the camera in Android for the first time and am hung up on a few things that seem to be required. I've given the app Camera permissions and I can see the thumbnail image.
After searching I found this google example that states I must create a file to see the full size image. Why? Also, in creating a file I have to ask the user for permission to write to disk. I have no intention of saving the photos, however I need to create a file and and now need to worry about file cleanup.
Lastly, this full sized image has no EXIF data. I've found a way to create a bitmap with the file to rotate the image. Is this correct? It seems like a lot of work to just see a correctly oriented image that i've just taken.
After searching I found this google example that states I must create a file to see the full size image. Why?
A full-size photo is much larger than the 1MB limit for Intent contents.
I have no intention of saving the photos, however I need to create a file and and now need to worry about file cleanup.
Then do not use ACTION_IMAGE_CAPTURE. Use the camera APIs directly (android.hardware.Camera, android.hardware.camera2.*) or via a third-party wrapper (Fotoapparat, CameraKit-Android).
this full sized image has no EXIF data
With ACTION_IMAGE_CAPTURE, you are delegating to whatever camera app the user happens to choose. That will be one of hundreds of camera apps, whether pre-installed on the user's chosen device or installed by the user from the Play Store or elsewhere. The behavior of those camera apps, with respect to EXIF tags and anything else, is up to the developers of those camera apps.
It is also possible that you are not reading the EXIF tags correctly.
After searching I found this google example that states I must create a file to see the full size image.
That is a nonsense statement in that document. You do not have to create a file yourself. You only need to supply a file path in the intent so the used Camera app knows where to store the image.
Further i never saw a camera app that didnot include an exif header.

Android create hidden picture activity using timer ,background save to sd card

I know using intent you can save jpeg from camera to sd card .
I need assistance :
I want to create a Timer that saves appends a jpeg from the camera at a certain specified interval to sd card .
I also want to create a function that automatically uploads the jpeg on new append to my webserver..
any assistance will be really appreciated basic idea is to . capture jpg on intervals and every pic saved to be auto uploaded to webserver.

How to avoid saving picture at gallery or delete it automatically in Android?

The device is Samsung Galaxy III. I developed an APP to run the camera activity and capture an image. After analyzing the image, I print out some text information. Right now every captured image is saved at gallery. I don't need the image to be saved in gallery or SD card. I think either of the following two solutions will work for me, but I don't know how to program it:
avoid saving pictures to gallery.
delete the picture somewhere in the APP.
Any comments are appreciated.
Read Android Camera tutorial.
...
Storage - Are the images or videos your application generates intended to be only visible to your application or shared so that other applications such as Gallery or other media and social apps can use them? Do you want the pictures and videos to be available even if your application is uninstalled? Check out the Saving Media Files section to see how to implement these options.
or see this one: How to save image captured with camera in specific folder.
In the Camera intent when starting, add this:
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(getTempFile(context)));
I solved my problem with following two steps:
as '#auselen' pointed, save all the images to a specific folder. How to save image captured with camera in specific folder.
delete all the images in that folder somewhere in the APP. How to Delete Image From SDCard in Android
use this for delete a pic
ImgPhoto1.setImageBitmap(null);

Categories

Resources