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
+692
-1051
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,7 @@
|
|||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
"beast-orm": "^1.1.2",
|
"beast-orm": "^1.1.2",
|
||||||
"bootstrap": "^4.5.0",
|
"bootstrap": "^4.5.0",
|
||||||
|
"browser-image-resizer": "^2.4.1",
|
||||||
"build": "0.1.4",
|
"build": "0.1.4",
|
||||||
"capacitor-voice-recorder": "^4.0.1",
|
"capacitor-voice-recorder": "^4.0.1",
|
||||||
"ci": "^2.1.1",
|
"ci": "^2.1.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as internal from "stream";
|
import * as internal from "stream";
|
||||||
|
|
||||||
export class DailyWorkTask{
|
export class DailyWorkTask {
|
||||||
SerialNumber: string;
|
SerialNumber: string;
|
||||||
Folio: string;
|
Folio: string;
|
||||||
Senders: string;
|
Senders: string;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera
|
|||||||
|
|
||||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||||
import { NgxImageCompressService } from "ngx-image-compress";
|
import { NgxImageCompressService } from "ngx-image-compress";
|
||||||
|
import { readAndCompressImage } from 'browser-image-resizer';
|
||||||
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async takePicture() {
|
async takePicture() {
|
||||||
|
alert('take')
|
||||||
const capturedImage = await Camera.getPhoto({
|
const capturedImage = await Camera.getPhoto({
|
||||||
quality: 90,
|
quality: 90,
|
||||||
// allowEditing: true,
|
// allowEditing: true,
|
||||||
@@ -119,11 +121,30 @@ export class NewPublicationPage implements OnInit {
|
|||||||
const response = await fetch(capturedImage.webPath!);
|
const response = await fetch(capturedImage.webPath!);
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
||||||
this.convertBlobToBase64Worker.postMessage(blob);
|
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.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||||
this.capturedImage = oEvent.data
|
this.capturedImage = oEvent.data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.then(result => {
|
||||||
|
// TODO: Handle the result
|
||||||
|
console.log('result', result);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imageSize(image) {
|
imageSize(image) {
|
||||||
@@ -180,11 +201,34 @@ export class NewPublicationPage implements OnInit {
|
|||||||
const response = await fetch(capturedImage.webPath!);
|
const response = await fetch(capturedImage.webPath!);
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
||||||
this.convertBlobToBase64Worker.postMessage(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.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||||
this.capturedImage = oEvent.data
|
this.capturedImage = oEvent.data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.then(result => {
|
||||||
|
// TODO: Handle the result
|
||||||
|
// console.log('result', result);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +242,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
this.Form = new FormGroup({
|
this.Form = new FormGroup({
|
||||||
Subject: new FormControl(this.pub.Title, [
|
Subject: new FormControl(this.pub.Title, [
|
||||||
//Validators.required,
|
Validators.required,
|
||||||
// Validators.minLength(4)
|
// Validators.minLength(4)
|
||||||
]),
|
]),
|
||||||
capturedImage: new FormControl(this.capturedImage, [
|
capturedImage: new FormControl(this.capturedImage, [
|
||||||
@@ -269,11 +313,11 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||||
this.toastService.successMessage("Publicação criado")
|
this.toastService._successMessage("Publicação criado")
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.toastService.badRequest("Publicação não criado")
|
this.toastService._badRequest("Publicação não criado")
|
||||||
} finally {
|
} finally {
|
||||||
loader.remove()
|
loader.remove()
|
||||||
}
|
}
|
||||||
@@ -297,11 +341,11 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||||
this.toastService.successMessage("Publicação criado")
|
this.toastService._successMessage("Publicação criado")
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.toastService.badRequest("Publicação não criado")
|
this.toastService._badRequest("Publicação não criado")
|
||||||
} finally {
|
} finally {
|
||||||
loader.remove()
|
loader.remove()
|
||||||
}
|
}
|
||||||
@@ -333,12 +377,12 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||||
this.close();
|
this.close();
|
||||||
this.toastService.successMessage("Publicação criado")
|
this.toastService._successMessage("Publicação criado")
|
||||||
|
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.toastService.badRequest("Publicação não criado")
|
this.toastService._badRequest("Publicação não criado")
|
||||||
} finally {
|
} finally {
|
||||||
loader.remove()
|
loader.remove()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "69a3dc9f8",
|
"shortSHA": "7e2691cf8",
|
||||||
"SHA": "69a3dc9f8123e5a9483879703cb78b6936b6c889",
|
"SHA": "7e2691cf8d9cf4ce2e2f652ff7ba199e2d7a5d0a",
|
||||||
"branch": "no_bug_movemente",
|
"branch": "no_bug_movemente",
|
||||||
"lastCommitAuthor": "'Peter Maquiran'",
|
"lastCommitAuthor": "'Peter Maquiran'",
|
||||||
"lastCommitTime": "'Wed Feb 8 16:26:52 2023 +0100'",
|
"lastCommitTime": "'Thu Feb 9 12:06:37 2023 +0100'",
|
||||||
"lastCommitMessage": "improve",
|
"lastCommitMessage": "publicate name",
|
||||||
"lastCommitNumber": "4758",
|
"lastCommitNumber": "4759",
|
||||||
"change": "",
|
"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"
|
"changeAuthor": "peter.maquiran"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user