Ionic Capacitor Camera Delete Image - ionic-framework

Im using the capacitor camera api to get Images. Im just interested in the base64 encoded image data. So I don't need any image pathes. Im using the following code:
const image = await Camera.getPhoto({
quality: 90,
allowEditing: false,
resultType: CameraResultType.Base64
});
I noticed the local "user data" increases by each image the user makes (tested on Android). The image gets stored somewhere (on Android its: "Android/data/com.mypackage/files/Pictures") I can't test it on iOS at the moment. I guess it behaves differently there.
Is there any good way to delete those image files?
I could get the image path if I change the resultType, read the image with the file api and convert it manually into base64 but it makes the resultType setting useless.
Any ideas?

Use Filesystem API to delete image temp when you're done in the image.
If you're using ionic native camera check here https://ionicframework.com/docs/v3/native/camera/, it has a function called cleanup() - Remove intermediate image files that are kept in temporary storage after calling camera.getPicture. Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.

Related

Getting difficulty in reading image from Disk for iphone in Unity

I am developing a unity app, in which i call webservice for image url and after getting those url, i call one by one url for image downloading and store those images onto disks, and after in some point i read those images from disks and show as texture, but i am getting problem in reading images. It show me Question mark on texture and when i dig more to find out problem i got that i am getting zero of image using www.size and text also nil using www.text. I am doing following for reading and writing images.
Writing
if(wwwMarker.isDone)
File.WriteAllBytes(Application.persistentDataPath + "/"+ data.markerName + ".jpg", wwwMarker.bytes);
Reading
//fileurl is string which contain path of file
fileUrl = (Application.persistentDataPath + "/"+ markerDataObject.markerName + ".jpg");
if(System.IO.File.Exists(fileUrl))
if(www.isDone)
video.mIconPlane.renderer.material.mainTexture = imageToLoadPath.texture;
But when i read this code and show render image on texture it show me Question mark image, but when i load images from assets it works perfectly fine. Please help me that where i am doing wrong. I am nee bee in unity so thats why doing silly mistakes. This will be great for me. Thanks in advance.
Note, that unity's WWW can only dowload and save as textures JPG and PNG images. If you will try to download an image of any other format, you will get a red "?" image as result.

How to save images in camera roll in iphone programmatically?

I am developing one application. In that I want to save my pictures in camera roll. So how to save my pictures in camera roll through code?
The most basic way (and the only way if you're targeting iOS before 4.0) is to use UIImageWriteToSavedPhotosAlbum. This lets you specify a selector to be called on a target object when the save is complete.
In 4.0, you can use ALAssetsLibrary's writeImageToSavedPhotosAlbum:orientation:completionBlock: to write the image; in this case, you provide a block to be called when the save is complete.
In 4.1, you can also use ALAssetsLibrary's writeImageDataToSavedPhotosAlbum:metadata:completionBlock: or writeImageToSavedPhotosAlbum:metadata:completionBlock: to write an image along with metadata (e.g. geotagging information). The former is also the only way to write an image from an NSData object without first loading it as a UIImage or CGImageRef.
See this blog post..UIImageWriteToSavedPhotosAlbum is your friend..

Is there any standard fileopen dialog in iphone programming?

I want to create application, that will process images(mostly - photographs from mobile camera).
So i need at first to provide the way to open image file from phone memory.
how can i do that?
Sorry for such a stupid question, but i am newbie in iphone programming(yet:)).
P.S. I use xcode, cocoa
You can use UIImagePickerController to get a standard interface for selecting a photo from the user's library or camera roll. Depending on the configuration, it can also be used to capture a new image with the camera. Note however that you get a UIImage back, not a file, if you want to upload it somewhere, you will first have to create a file or NSData object from the image, using either UIImagePNGRepresentation() or UIImageJPEGRepresentation().

How do i get the image name of a image in imageView?

Hi i want to upload the image to HTTP server, image upload is working fine but every time the image in the server is replaced with the new image. Can some one help me to implement the commented lines below.
Thanks...
- (IBAction)upload{
//NSString *imagename=imageview.image;
//[self uploadImage:UIImageJPEGRepresentation(imageview.image, 1.0) filename:imagename];
[self uploadImage:UIImageJPEGRepresentation(imageview.image, 1.0) filename:#"facebook.jpg"];
}
To get the image's filename, capture the name during the file picking (but remember, maybe the image in the image view comes directly from the camera).
If the file upload should never overwrite a file already on the server, consider one of the following:
a) generate a unique filename for each upload (preferably in the server code, but if you also control the client, you can do it there too). You could use UUIDs as unique filenames.
OR
b) store the images in a database instead of the filesystem

Is there a way to get paths of all the images of CAmera roll

Is there any way to create an array or something
having paths of all the images stored in camera roll.
Please enlighten me on this.
Thnx in advance
SpyPhone uses a direct path to the users photo library:
http://github.com/nst/spyphone/
It seems that any application can read it. However, this seems like falls under the area of "undocumented API" and could well be rejected in a real application.
I don't think there is. As far as the API is concerned for the UIImagePickerController you can only get a single path for a Movie that was recorded by the user (if running 3.0 on a 3GS). And even that path is a file URL to the temporary folder where the movie is stored before being written to the library.
You can't get paths for any images in the photo library or the camera roll.
When you pick an image using the UIImagePickerController the controller returns the Original Image and an "Edited Image" if the image was edited before being chosen.