Untitled
// image-upload.component.ts import { Component } from '@angular/core'; import Swal from 'sweetalert2'; @Component({ selector: 'app-image-upload', templateUrl: './image-upload.component.html', styleUrls: ['./image-upload.component.css'] }) export class ImageUploadComponent { images: File[] = []; onFilesSelected(event: any) { const files = event.target.files; this.images = Array.from(files); for (const image of this.images) { const img = new Image(); const reader = new FileReader(); reader.onload = (e: any) => { img.src = e.target.result; }; img.onload = () => { const widthInInches = img.width / 96; // Assuming 96 DPI const heightInInches = img.height / 96; // Assuming 96 DPI if (widthInInches < 2 || heightInInches < 2) { Swal.fire({ icon: 'warning', title: 'Image too small', text: 'Each image must be at least 2 x 2 inches in size.', }); } }; reader.readAsDataURL(image); } } }
Leave a Comment