@bitforgehq/angular-ionic-image-cropper
Version:
An Ionic Angular library for cross platform image cropping.
87 lines (82 loc) • 3.35 kB
TypeScript
import * as i0 from '@angular/core';
import { AfterViewInit, EventEmitter, ElementRef } from '@angular/core';
import { ModalController } from '@ionic/angular/standalone';
declare class ImageCropperComponent implements AfterViewInit {
private modalCtrl;
imageUrl: string;
aspectRatio: number;
cancelText: string;
doneText: string;
quality: number;
outputFormat: 'image/jpeg' | 'image/png' | 'image/webp';
cropComplete: EventEmitter<Blob>;
imageElement: ElementRef<HTMLImageElement>;
cropperContainer: ElementRef<HTMLDivElement>;
private cropper;
constructor(modalCtrl: ModalController);
ngAfterViewInit(): void;
private initializeCropper;
crop(): void;
cancel(): void;
getCroppedImage(): Promise<Blob>;
static ɵfac: i0.ɵɵFactoryDeclaration<ImageCropperComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ImageCropperComponent, "lib-angular-ionic-image-cropper", never, { "imageUrl": { "alias": "imageUrl"; "required": false; }; "aspectRatio": { "alias": "aspectRatio"; "required": false; }; "cancelText": { "alias": "cancelText"; "required": false; }; "doneText": { "alias": "doneText"; "required": false; }; "quality": { "alias": "quality"; "required": false; }; "outputFormat": { "alias": "outputFormat"; "required": false; }; }, { "cropComplete": "cropComplete"; }, never, never, true, never>;
}
/**
* Configuration options for the image cropper
*/
interface ImageCropperConfig {
/**
* Text to display on the cancel button
* @default 'Cancel'
*/
cancelText?: string;
/**
* Text to display on the done/confirm button
* @default 'Done'
*/
doneText?: string;
/**
* Aspect ratio for the crop area (width / height)
* Common values: 1 (square), 16/9 (widescreen), 4/3 (standard)
* @default 16/9
*/
aspectRatio?: number;
/**
* Quality of the output image (0.1 to 1.0)
* @default 0.9
*/
quality?: number;
/**
* Output format for the cropped image
* @default 'image/jpeg'
*/
outputFormat?: 'image/jpeg' | 'image/png' | 'image/webp';
}
/**
* Service for handling image cropping operations with Ionic integration
*/
declare class ImageCropperService {
private modalCtrl;
constructor(modalCtrl: ModalController);
/**
* Opens the image cropper modal with the specified image
* @param imagePath - Path or URL to the image to crop
* @param config - Configuration options for the cropper
* @returns Promise that resolves to the cropped image as a Blob
* @throws Error if the crop operation is cancelled
*/
openCropper(imagePath: string, config?: ImageCropperConfig): Promise<Blob>;
/**
* Takes a photo using the device camera and opens the cropper
* @param config - Configuration options for the cropper
* @returns Promise that resolves to the cropped image as a Blob
* @throws Error if photo capture or crop operation fails
*/
takeAndCropPhoto(config?: ImageCropperConfig): Promise<Blob>;
static ɵfac: i0.ɵɵFactoryDeclaration<ImageCropperService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ImageCropperService>;
}
declare const STYLES = "./styles.scss";
export { ImageCropperComponent, ImageCropperService, STYLES };
export type { ImageCropperConfig };