Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

How to save easier an image taken by the cam on Ionic 4?

$
0
0

@Manel00 wrote:

Hi everyone,

I’m trying to take a pic and save it on local storage, but i dont know too much about base64 (it’s the type which one retrieves the camera) and i miss some easy way. But the problem is there’s no new way to do it easier, anyone knows some way actually? Thank you so much

I’m following this tutorials, but it doesnt convince me, as you can see there are too many beta versions and don’t know what to use “ionic-native”, “capacitor” or “cordova”? too much information and no-updated…

https://tphangout.com/ionic-4-camera-with-capacitor/
https://devdactic.com/ionic-4-image-upload-storage/

My Code:

	startCamera() {

		const options: CameraOptions = {
			quality: 100,
			destinationType: this.camera.DestinationType.FILE_URI,
			encodingType: this.camera.EncodingType.JPEG,
			mediaType: this.camera.MediaType.PICTURE
		}

		this.camera.getPicture(options).then(imageData => {
			// imageData is either a base64 encoded string or a file URI
			// If it's base64 (DATA_URL):
			//let base64Image = 'data:image/jpeg;base64,' + imageData;
			var currentName = imageData.substring(imageData.lastIndexOf('/') + 1);
			var correctPath = imageData.substring(0, imageData.lastIndexOf('/'))
		}, (err) => {
			this.user.presentAlert("Error", err)
		});
	}

	createFilename() {
		var d = new Date(),
			n = d.getTime(),
			newFilename = n + ".jpg";
		return newFilename;
	}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>