Reputation: 326
I am having a problem with the resolution of the photos in my application. My TS file. this with the following configuration:
import { Component, OnInit } from '@angular/core';
import { PictureSourceType, Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { Router } from '@angular/router';
import { ActionSheetController } from '@ionic/angular';
@Component({
selector: 'app-pic-register',
templateUrl: './pic-register.page.html',
styleUrls: ['./pic-register.page.scss'],
})
export class PicRegisterPage implements OnInit {
public photo: string;
constructor(
private router: Router,
private camera: Camera,
private ActionSheetController: ActionSheetController
) { }
ngOnInit() {
}
updateStoredImage(image) {
}
documentFront(){
console.log('aqui');
this.router.navigateByUrl('/register/document-front')
}
async selectImage() {
const actionSheet = await this.ActionSheetController.create({
header: 'Selecione uma image',
buttons: [{
text: 'Galeria',
icon: 'file-tray-full-outline',
handler: () => {
this.takePicture(this.camera.PictureSourceType.PHOTOLIBRARY);
}
}, {
text: 'Camera',
icon: 'camera',
handler: () => {
this.takePicture(this.camera.PictureSourceType.CAMERA)
}
}, {
text: 'Cancelar',
role: 'cancel',
icon: 'log-out-outline',
}]
});
await actionSheet.present();
}
takePicture(sourceType: PictureSourceType) {
this.photo = '';
var options: CameraOptions = {
quality: 100,
sourceType: sourceType,
saveToPhotoAlbum: false,
correctOrientation: true,
destinationType: this.camera.DestinationType.NATIVE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
targetWidth: 100,
targetHeight: 100
}
this.camera.getPicture(options).then(imageData => {
let base64image = 'data:image/jpeg;base64,' + imageData;
this.photo = base64image;
}, error =>{
console.log(error);
}).catch(error => {
console.log(error);
})
}
}
Someone would know what error is running since in the camera options I put the quality to 100. Any photo that comes from the gallery or the camera is being rendered with this low quality within the application.
Upvotes: 1
Views: 691
Reputation: 33345
your target width and height are too low... remove them or set them higher
Upvotes: 1