mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Merge branch 'developer' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -19,6 +19,7 @@ import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
|
||||
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { NgxImageCompressService } from "ngx-image-compress";
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -72,6 +73,9 @@ export class NewPublicationPage implements OnInit {
|
||||
capturedImageTitle: any;
|
||||
public photos: any[] = [];
|
||||
|
||||
imgResultBeforeCompress: string;
|
||||
imgResultAfterCompress: string;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
public photoService: PhotoService,
|
||||
@@ -83,6 +87,7 @@ export class NewPublicationPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
private platform: Platform,
|
||||
private loadingCtrl: LoadingController,
|
||||
public imageCompress: NgxImageCompressService
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -104,13 +109,13 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
async takePicture() {
|
||||
const image = await Camera.getPhoto({
|
||||
quality: 50,
|
||||
quality: 20,
|
||||
allowEditing: false,
|
||||
width:50,
|
||||
height: 50,
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (image) {
|
||||
@@ -120,13 +125,13 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
imageSize(image){
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
canvas.width=100
|
||||
canvas.height=34
|
||||
ctx.drawImage(image, 0, 0, 100, 34);
|
||||
document.body.appendChild(canvas);
|
||||
imageSize(image) {
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
canvas.width = 100
|
||||
canvas.height = 34
|
||||
ctx.drawImage(image, 0, 0, 100, 34);
|
||||
document.body.appendChild(canvas);
|
||||
}
|
||||
|
||||
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
|
||||
@@ -394,9 +399,13 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
async selectImage() {
|
||||
const image = await Camera.getPhoto({
|
||||
<<<<<<< HEAD
|
||||
quality: 50,
|
||||
width:50,
|
||||
height:50,
|
||||
=======
|
||||
quality: 20,
|
||||
>>>>>>> 6a912b740d97159664c5fe5dff07ac378b028771
|
||||
allowEditing: false,
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||
@@ -407,7 +416,7 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Create a new file from a capture image
|
||||
async saveImage(photo: Photo) {
|
||||
@@ -496,12 +505,43 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
this.capturedImage = this.images[0].data
|
||||
|
||||
this.compressFile();
|
||||
|
||||
loading.dismiss();
|
||||
|
||||
}
|
||||
|
||||
/* compressImage() {
|
||||
let image = this.capturedImage;
|
||||
this.imageCompress.compressFile(image, orientation, 50, 50,).then(() => {
|
||||
|
||||
this.imgResultBeforeCompress = image;
|
||||
console.log('Size in bytes was:', this.imageCompress.byteCount(image));
|
||||
|
||||
this.imageCompress.compressFile(image, orientation, 50, 50).then(
|
||||
result => {
|
||||
this.imgResultAfterCompress = result;
|
||||
console.log('Size in bytes is now:', this.imageCompress.byteCount(result));
|
||||
}
|
||||
);
|
||||
})
|
||||
} */
|
||||
|
||||
compressFile() {
|
||||
|
||||
//this.imgResultBeforeCompress = image;
|
||||
this.imageCompress.getOrientation(this.capturedImage).then((orientation) => {
|
||||
console.log('Size in bytes was:', this.imageCompress.byteCount(this.capturedImage));
|
||||
this.imageCompress.compressFile(this.capturedImage, orientation, 20, 20).then(
|
||||
result => {
|
||||
this.capturedImage = result;
|
||||
console.log('Size in bytes is now:', this.imageCompress.byteCount(result));
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user