mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add take picture
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ModalController, NavParams, Platform, LoadingController } from '@ionic/angular';
|
||||
import { ModalController, NavParams, Platform, LoadingController, PopoverController } from '@ionic/angular';
|
||||
|
||||
/* import {Plugins, CameraResultType, CameraSource} from '@capacitor/core'; */
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
@@ -20,6 +20,7 @@ import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera
|
||||
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { NgxImageCompressService } from "ngx-image-compress";
|
||||
import { PreviewerPage } from 'src/app/modals/previewer/previewer.page';
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
interface LocalFile {
|
||||
@@ -74,9 +75,11 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
imgResultBeforeCompress: string;
|
||||
imgResultAfterCompress: string;
|
||||
convertBlobToBase64Worker;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private popoverController: PopoverController,
|
||||
public photoService: PhotoService,
|
||||
private navParams: NavParams,
|
||||
private publications: PublicationsService,
|
||||
@@ -92,6 +95,10 @@ export class NewPublicationPage implements OnInit {
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
this.folderId = this.navParams.get('folderId');
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
|
||||
|
||||
this.convertBlobToBase64Worker = new Worker(new URL('./convertBlobToBase64.worker.js', import.meta.url));
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -106,7 +113,10 @@ export class NewPublicationPage implements OnInit {
|
||||
// this.takePicture();
|
||||
}
|
||||
|
||||
imageUrl;
|
||||
|
||||
async takePicture() {
|
||||
|
||||
const capturedImage = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
@@ -114,19 +124,17 @@ export class NewPublicationPage implements OnInit {
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
console.log(capturedImage)
|
||||
const response = await fetch(capturedImage.webPath!);
|
||||
this.imageUrl = capturedImage.webPath
|
||||
const blob = await response.blob();
|
||||
|
||||
this.photos.unshift({
|
||||
filepath: "soon...",
|
||||
webviewPath: capturedImage.webPath
|
||||
});
|
||||
this.capturedImage = await this.convertBlobToBase64(blob);
|
||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
||||
//console.log(this.capturedImage);
|
||||
}
|
||||
|
||||
this.convertBlobToBase64Worker.postMessage(blob);
|
||||
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||
this.capturedImage = oEvent.data
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
imageSize(image) {
|
||||
var canvas = document.createElement('canvas');
|
||||
|
||||
Reference in New Issue
Block a user