mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix take picture immage to big
This commit is contained in:
Generated
+694
-1053
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,7 @@
|
||||
"base64-js": "^1.5.1",
|
||||
"beast-orm": "^1.1.2",
|
||||
"bootstrap": "^4.5.0",
|
||||
"browser-image-resizer": "^2.4.1",
|
||||
"build": "0.1.4",
|
||||
"capacitor-voice-recorder": "^4.0.1",
|
||||
"ci": "^2.1.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as internal from "stream";
|
||||
|
||||
export class DailyWorkTask{
|
||||
export class DailyWorkTask {
|
||||
SerialNumber: string;
|
||||
Folio: string;
|
||||
Senders: string;
|
||||
|
||||
@@ -18,6 +18,8 @@ import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera
|
||||
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { NgxImageCompressService } from "ngx-image-compress";
|
||||
import { readAndCompressImage } from 'browser-image-resizer';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -108,7 +110,7 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
async takePicture() {
|
||||
|
||||
alert('take')
|
||||
const capturedImage = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
@@ -119,11 +121,30 @@ export class NewPublicationPage implements OnInit {
|
||||
const response = await fetch(capturedImage.webPath!);
|
||||
const blob = await response.blob();
|
||||
|
||||
this.convertBlobToBase64Worker.postMessage(blob);
|
||||
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||
this.capturedImage = oEvent.data
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
maxWidth: 800,
|
||||
debug: true
|
||||
};
|
||||
|
||||
var file = new File([blob], "camera.jpg");
|
||||
|
||||
// Note: A single file comes from event.target.files on <input>
|
||||
readAndCompressImage(file, config)
|
||||
.then(resizedImage => {
|
||||
console.log('resizedImage', resizedImage);
|
||||
|
||||
this.convertBlobToBase64Worker.postMessage(resizedImage);
|
||||
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||
this.capturedImage = oEvent.data
|
||||
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
// TODO: Handle the result
|
||||
console.log('result', result);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
imageSize(image) {
|
||||
@@ -179,12 +200,35 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
const response = await fetch(capturedImage.webPath!);
|
||||
const blob = await response.blob();
|
||||
|
||||
|
||||
const config = {
|
||||
quality: 0.9,
|
||||
maxWidth: 800,
|
||||
debug: !environment.production
|
||||
};
|
||||
|
||||
var file = new File([blob], "camera.jpg");
|
||||
|
||||
// Note: A single file comes from event.target.files on <input>
|
||||
readAndCompressImage(file, config)
|
||||
.then(resizedImage => {
|
||||
console.log('resizedImage', resizedImage);
|
||||
|
||||
this.convertBlobToBase64Worker.postMessage(resizedImage);
|
||||
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||
this.capturedImage = oEvent.data
|
||||
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
// TODO: Handle the result
|
||||
// console.log('result', result);
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.convertBlobToBase64Worker.postMessage(blob);
|
||||
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||
this.capturedImage = oEvent.data
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -198,7 +242,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
this.Form = new FormGroup({
|
||||
Subject: new FormControl(this.pub.Title, [
|
||||
//Validators.required,
|
||||
Validators.required,
|
||||
// Validators.minLength(4)
|
||||
]),
|
||||
capturedImage: new FormControl(this.capturedImage, [
|
||||
@@ -269,11 +313,11 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
try {
|
||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
this.toastService.successMessage("Publicação criado")
|
||||
this.toastService._successMessage("Publicação criado")
|
||||
|
||||
this.close();
|
||||
} catch (error) {
|
||||
this.toastService.badRequest("Publicação não criado")
|
||||
this.toastService._badRequest("Publicação não criado")
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
@@ -297,11 +341,11 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
try {
|
||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
this.toastService.successMessage("Publicação criado")
|
||||
this.toastService._successMessage("Publicação criado")
|
||||
|
||||
this.close();
|
||||
} catch (error) {
|
||||
this.toastService.badRequest("Publicação não criado")
|
||||
this.toastService._badRequest("Publicação não criado")
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
@@ -333,12 +377,12 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||
this.close();
|
||||
this.toastService.successMessage("Publicação criado")
|
||||
this.toastService._successMessage("Publicação criado")
|
||||
|
||||
|
||||
this.close();
|
||||
} catch (error) {
|
||||
this.toastService.badRequest("Publicação não criado")
|
||||
this.toastService._badRequest("Publicação não criado")
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export let versionData = {
|
||||
"shortSHA": "69a3dc9f8",
|
||||
"SHA": "69a3dc9f8123e5a9483879703cb78b6936b6c889",
|
||||
"shortSHA": "7e2691cf8",
|
||||
"SHA": "7e2691cf8d9cf4ce2e2f652ff7ba199e2d7a5d0a",
|
||||
"branch": "no_bug_movemente",
|
||||
"lastCommitAuthor": "'Peter Maquiran'",
|
||||
"lastCommitTime": "'Wed Feb 8 16:26:52 2023 +0100'",
|
||||
"lastCommitMessage": "improve",
|
||||
"lastCommitNumber": "4758",
|
||||
"lastCommitTime": "'Thu Feb 9 12:06:37 2023 +0100'",
|
||||
"lastCommitMessage": "publicate name",
|
||||
"lastCommitNumber": "4759",
|
||||
"change": "",
|
||||
"changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.html",
|
||||
"changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/models/dailyworktask.model.ts\n\tmodified: src/app/pages/publications/new-publication/new-publication.page.ts",
|
||||
"changeAuthor": "peter.maquiran"
|
||||
}
|
||||
Reference in New Issue
Block a user