cropp componet created

This commit is contained in:
Equilibrium ITO
2024-03-26 14:25:39 +01:00
parent 272f4d48bd
commit 92631cb4ee
6 changed files with 131 additions and 0 deletions
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { CropImagePage } from './crop-image.page';
const routes: Routes = [
{
path: '',
component: CropImagePage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class CropImagePageRoutingModule {}
@@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { CropImagePageRoutingModule } from './crop-image-routing.module';
import { CropImagePage } from './crop-image.page';
import { ImageCropperModule } from 'ngx-image-cropper';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
CropImagePageRoutingModule,
ImageCropperModule
],
declarations: [CropImagePage]
})
export class CropImagePageModule {}
@@ -0,0 +1,22 @@
<ion-header>
<ion-toolbar>
<ion-title>cropImage</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<!-- <div style="height: 100%; width: 100%;">
<image-cropper
[imageBase64]="this.capturedImage"
[maintainAspectRatio]="true"
[aspectRatio]="1 / 1"
format="jpeg"
allowMoveImage="true"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded($event)"
(loadImageFailed)="loadImageFailed()"
></image-cropper>
</div> -->
</ion-content>
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { CropImagePage } from './crop-image.page';
describe('CropImagePage', () => {
let component: CropImagePage;
let fixture: ComponentFixture<CropImagePage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ CropImagePage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(CropImagePage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,46 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ImageCroppedEvent, ImageCropperComponent } from 'ngx-image-cropper';
@Component({
selector: 'app-crop-image',
templateUrl: './crop-image.page.html',
styleUrls: ['./crop-image.page.scss'],
})
export class CropImagePage implements OnInit {
imageChangedEvent: any = '';
croppedImage: any = '';
@ViewChild('cropper') cropper: ImageCropperComponent;
capturedImage: any = "";
constructor() { }
ngOnInit() {
}
fileChangeEvent(event: any): void {
this.imageChangedEvent = event;
}
imageCropped(event: ImageCroppedEvent) {
this.croppedImage = event.base64;
console.log('Croped image',event)
console.log('Croped image 22',this.croppedImage)
// event.blob can be used to upload the cropped image
}
/* cropperReady() {
if(this.croppedImage != '')
var fileObject = {
FileBase64: this.croppedImage,
FileExtension: 'jpeg',
OriginalFileName: 'image',
FileSize: this.fileSizeToMB(this.croppedImage.length)
}
this.seletedContent.push(fileObject)
return true
}
loadImageFailed() {
// show message
} */
}