New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-image-cropper

Package Overview
Dependencies
Maintainers
0
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-image-cropper - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

esm2022/lib/component/cropper.state.mjs

120

lib/component/image-cropper.component.d.ts

@@ -1,29 +0,24 @@

import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { DomSanitizer, HammerLoader, SafeStyle, SafeUrl } from '@angular/platform-browser';
import { CropperPosition, Dimensions, ImageCroppedEvent, ImageTransform, LoadedImage } from '../interfaces';
import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { DomSanitizer, SafeStyle, SafeUrl } from '@angular/platform-browser';
import { CropperOptions, CropperPosition, Dimensions, ImageCroppedEvent, ImageTransform, LoadedImage } from '../interfaces';
import { OutputFormat } from '../interfaces/cropper-options.interface';
import { MoveTypes } from '../interfaces/move-start.interface';
import { CropService } from '../services/crop.service';
import { CropperPositionService } from '../services/cropper-position.service';
import { LoadImageService } from '../services/load-image.service';
import { BasicEvent } from "../interfaces/basic-event.interface";
import { CropperState } from './cropper.state';
import { MoveTypes, Position } from '../interfaces/move-start.interface';
import { BasicEvent } from '../interfaces/basic-event.interface';
import * as i0 from "@angular/core";
export declare class ImageCropperComponent implements OnChanges, OnInit {
private cropService;
private cropperPositionService;
private loadImageService;
export declare class ImageCropperComponent implements OnChanges, OnInit, OnDestroy {
private sanitizer;
private cd;
private zone;
private readonly hammerLoader;
private settings;
private readonly pinchStart$;
private readonly cropService;
private readonly loadImageService;
private setImageMaxSizeRetries;
private moveStart?;
private loadedImage?;
private resizedWhileHidden;
safeImgDataUrl?: SafeUrl | string;
protected readonly moveTypes: typeof MoveTypes;
protected readonly state: CropperState;
readonly safeImgDataUrl: import("@angular/core").WritableSignal<string | SafeUrl | undefined>;
safeTransformStyle?: SafeStyle | string;
marginLeft: SafeStyle | string;
maxSize: Dimensions;
moveTypes: typeof MoveTypes;
imageVisible: boolean;

@@ -37,29 +32,31 @@ wrapper: ElementRef<HTMLDivElement>;

imageAltText?: string;
cropperFrameAriaLabel: string;
output: 'blob' | 'base64';
format: OutputFormat;
transform: ImageTransform;
maintainAspectRatio: boolean;
aspectRatio: number;
resetCropOnAspectRatioChange: boolean;
resizeToWidth: number;
resizeToHeight: number;
cropperMinWidth: number;
cropperMinHeight: number;
cropperMaxHeight: number;
cropperMaxWidth: number;
cropperStaticWidth: number;
cropperStaticHeight: number;
canvasRotation: number;
initialStepSize: number;
roundCropper: boolean;
onlyScaleDown: boolean;
imageQuality: number;
autoCrop: boolean;
backgroundColor: string | null;
containWithinAspectRatio: boolean;
hideResizeSquares: boolean;
options?: Partial<CropperOptions>;
cropperFrameAriaLabel?: string;
output?: 'blob' | 'base64';
format?: OutputFormat;
autoCrop?: boolean;
cropper?: CropperPosition;
transform?: ImageTransform;
maintainAspectRatio?: boolean;
aspectRatio?: number;
resetCropOnAspectRatioChange?: boolean;
resizeToWidth?: number;
resizeToHeight?: number;
cropperMinWidth?: number;
cropperMinHeight?: number;
cropperMaxHeight?: number;
cropperMaxWidth?: number;
cropperStaticWidth?: number;
cropperStaticHeight?: number;
canvasRotation?: number;
initialStepSize?: number;
roundCropper?: boolean;
onlyScaleDown?: boolean;
imageQuality?: number;
backgroundColor?: string;
containWithinAspectRatio?: boolean;
hideResizeSquares?: boolean;
allowMoveImage: boolean;
cropper: CropperPosition;
alignImage: 'left' | 'center';
checkImageType: boolean;
alignImage?: 'left' | 'center';
disabled: boolean;

@@ -73,9 +70,9 @@ hidden: boolean;

transformChange: EventEmitter<ImageTransform>;
constructor(cropService: CropService, cropperPositionService: CropperPositionService, loadImageService: LoadImageService, sanitizer: DomSanitizer, cd: ChangeDetectorRef, zone: NgZone, hammerLoader: HammerLoader | null);
cropperChange: EventEmitter<CropperPosition>;
get alignImageStyle(): "left" | "center";
constructor(sanitizer: DomSanitizer, cd: ChangeDetectorRef, zone: NgZone);
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): void;
private onChangesUpdateSettings;
private onChangesInputImage;
private isValidImageChangedEvent;
private setCssTransform;
ngOnInit(): void;
private reset;

@@ -87,2 +84,3 @@ private loadImageFile;

loadImageError(error: unknown): void;
private setCssTransform;
imageLoadedInView(): void;

@@ -92,21 +90,15 @@ private checkImageMaxSizeRecursively;

onResize(): void;
private activatePinchGesture;
private resizeCropperPosition;
resetCropperPosition(): void;
keyboardAccess(event: KeyboardEvent): void;
private changeKeyboardStepSize;
private keyboardMoveCropper;
startMove(event: Event | BasicEvent, moveType: MoveTypes, position?: string | null): void;
startMove(event: Event | BasicEvent, moveType: MoveTypes, position?: Position | null): void;
private initMouseMove;
startPinch(event: any): void;
private handleMouseMove;
onPinch(event: any): void;
private handleMouseUp;
startPinch(event: TouchEvent): void;
private initPinch;
handlePinchMove(event: TouchEvent): void;
handlePinchStop(): void;
private setMaxSize;
private setCropperScaledMinSize;
private setCropperScaledMinWidth;
private setCropperScaledMinHeight;
private setCropperScaledMaxSize;
private checkCropperPosition;
private handleMouseUp;
pinchStop(): void;
private emitCropperPositionChange;
private doAutoCrop;

@@ -118,5 +110,5 @@ crop(): ImageCroppedEvent | null;

private cropToBase64;
private aspectRatioIsCorrect;
static ɵfac: i0.ɵɵFactoryDeclaration<ImageCropperComponent, [null, null, null, null, null, null, { optional: true; }]>;
static ɵcmp: i0.ɵɵComponentDeclaration<ImageCropperComponent, "image-cropper", never, { "imageChangedEvent": { "alias": "imageChangedEvent"; "required": false; }; "imageURL": { "alias": "imageURL"; "required": false; }; "imageBase64": { "alias": "imageBase64"; "required": false; }; "imageFile": { "alias": "imageFile"; "required": false; }; "imageAltText": { "alias": "imageAltText"; "required": false; }; "cropperFrameAriaLabel": { "alias": "cropperFrameAriaLabel"; "required": false; }; "output": { "alias": "output"; "required": false; }; "format": { "alias": "format"; "required": false; }; "transform": { "alias": "transform"; "required": false; }; "maintainAspectRatio": { "alias": "maintainAspectRatio"; "required": false; }; "aspectRatio": { "alias": "aspectRatio"; "required": false; }; "resetCropOnAspectRatioChange": { "alias": "resetCropOnAspectRatioChange"; "required": false; }; "resizeToWidth": { "alias": "resizeToWidth"; "required": false; }; "resizeToHeight": { "alias": "resizeToHeight"; "required": false; }; "cropperMinWidth": { "alias": "cropperMinWidth"; "required": false; }; "cropperMinHeight": { "alias": "cropperMinHeight"; "required": false; }; "cropperMaxHeight": { "alias": "cropperMaxHeight"; "required": false; }; "cropperMaxWidth": { "alias": "cropperMaxWidth"; "required": false; }; "cropperStaticWidth": { "alias": "cropperStaticWidth"; "required": false; }; "cropperStaticHeight": { "alias": "cropperStaticHeight"; "required": false; }; "canvasRotation": { "alias": "canvasRotation"; "required": false; }; "initialStepSize": { "alias": "initialStepSize"; "required": false; }; "roundCropper": { "alias": "roundCropper"; "required": false; }; "onlyScaleDown": { "alias": "onlyScaleDown"; "required": false; }; "imageQuality": { "alias": "imageQuality"; "required": false; }; "autoCrop": { "alias": "autoCrop"; "required": false; }; "backgroundColor": { "alias": "backgroundColor"; "required": false; }; "containWithinAspectRatio": { "alias": "containWithinAspectRatio"; "required": false; }; "hideResizeSquares": { "alias": "hideResizeSquares"; "required": false; }; "allowMoveImage": { "alias": "allowMoveImage"; "required": false; }; "cropper": { "alias": "cropper"; "required": false; }; "alignImage": { "alias": "alignImage"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "hidden": { "alias": "hidden"; "required": false; }; }, { "imageCropped": "imageCropped"; "startCropImage": "startCropImage"; "imageLoaded": "imageLoaded"; "cropperReady": "cropperReady"; "loadImageFailed": "loadImageFailed"; "transformChange": "transformChange"; }, never, never, true, never>;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<ImageCropperComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ImageCropperComponent, "image-cropper", never, { "imageChangedEvent": { "alias": "imageChangedEvent"; "required": false; }; "imageURL": { "alias": "imageURL"; "required": false; }; "imageBase64": { "alias": "imageBase64"; "required": false; }; "imageFile": { "alias": "imageFile"; "required": false; }; "imageAltText": { "alias": "imageAltText"; "required": false; }; "options": { "alias": "options"; "required": false; }; "cropperFrameAriaLabel": { "alias": "cropperFrameAriaLabel"; "required": false; }; "output": { "alias": "output"; "required": false; }; "format": { "alias": "format"; "required": false; }; "autoCrop": { "alias": "autoCrop"; "required": false; }; "cropper": { "alias": "cropper"; "required": false; }; "transform": { "alias": "transform"; "required": false; }; "maintainAspectRatio": { "alias": "maintainAspectRatio"; "required": false; }; "aspectRatio": { "alias": "aspectRatio"; "required": false; }; "resetCropOnAspectRatioChange": { "alias": "resetCropOnAspectRatioChange"; "required": false; }; "resizeToWidth": { "alias": "resizeToWidth"; "required": false; }; "resizeToHeight": { "alias": "resizeToHeight"; "required": false; }; "cropperMinWidth": { "alias": "cropperMinWidth"; "required": false; }; "cropperMinHeight": { "alias": "cropperMinHeight"; "required": false; }; "cropperMaxHeight": { "alias": "cropperMaxHeight"; "required": false; }; "cropperMaxWidth": { "alias": "cropperMaxWidth"; "required": false; }; "cropperStaticWidth": { "alias": "cropperStaticWidth"; "required": false; }; "cropperStaticHeight": { "alias": "cropperStaticHeight"; "required": false; }; "canvasRotation": { "alias": "canvasRotation"; "required": false; }; "initialStepSize": { "alias": "initialStepSize"; "required": false; }; "roundCropper": { "alias": "roundCropper"; "required": false; }; "onlyScaleDown": { "alias": "onlyScaleDown"; "required": false; }; "imageQuality": { "alias": "imageQuality"; "required": false; }; "backgroundColor": { "alias": "backgroundColor"; "required": false; }; "containWithinAspectRatio": { "alias": "containWithinAspectRatio"; "required": false; }; "hideResizeSquares": { "alias": "hideResizeSquares"; "required": false; }; "allowMoveImage": { "alias": "allowMoveImage"; "required": false; }; "checkImageType": { "alias": "checkImageType"; "required": false; }; "alignImage": { "alias": "alignImage"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "hidden": { "alias": "hidden"; "required": false; }; }, { "imageCropped": "imageCropped"; "startCropImage": "startCropImage"; "imageLoaded": "imageLoaded"; "cropperReady": "cropperReady"; "loadImageFailed": "loadImageFailed"; "transformChange": "transformChange"; "cropperChange": "cropperChange"; }, never, never, true, never>;
}

@@ -1,7 +0,7 @@

import { ImageTransform } from './image-transform.interface';
export interface CropperOptions {
format: OutputFormat;
output: OutputType;
autoCrop: boolean;
maintainAspectRatio: boolean;
resetCropOnAspectRatioChange: boolean;
transform: ImageTransform;
aspectRatio: number;

@@ -17,13 +17,13 @@ resizeToWidth: number;

canvasRotation: number;
initialStepSize: number;
roundCropper: boolean;
onlyScaleDown: boolean;
imageQuality: number;
autoCrop: boolean;
backgroundColor: string;
backgroundColor: string | null;
containWithinAspectRatio: boolean;
hideResizeSquares: boolean;
alignImage: 'left' | 'center';
cropperFrameAriaLabel: string | undefined;
checkImageType: boolean;
}
export type OutputFormat = 'png' | 'jpeg' | 'bmp' | 'webp' | 'ico';
export type OutputType = 'base64' | 'blob';

@@ -8,2 +8,1 @@ export { CropperOptions, OutputFormat } from './cropper-options.interface';

export { LoadedImage } from './loaded-image.interface';
export { CropperSettings } from './cropper.settings';

@@ -1,11 +0,9 @@

import { ImageTransform } from './image-transform.interface';
import { CropperPosition, ImageTransform } from './';
export type Position = 'left' | 'topleft' | 'top' | 'topright' | 'right' | 'bottomright' | 'bottom' | 'bottomleft' | 'center';
export interface MoveStart {
active: boolean;
type: MoveTypes | null;
position: string | null;
position: Position | null;
transform?: ImageTransform;
x1: number;
y1: number;
x2: number;
y2: number;
cropper: CropperPosition;
clientX: number;

@@ -12,0 +10,0 @@ clientY: number;

@@ -1,7 +0,6 @@

import { CropperPosition, Dimensions, ImageCroppedEvent, LoadedImage } from '../interfaces';
import { CropperSettings } from '../interfaces/cropper.settings';
import * as i0 from "@angular/core";
import { CropperOptions, ImageCroppedEvent } from '../interfaces';
import { CropperState } from '../component/cropper.state';
export declare class CropService {
crop(loadedImage: LoadedImage, cropper: CropperPosition, settings: CropperSettings, output: 'blob', maxSize: Dimensions): Promise<ImageCroppedEvent> | null;
crop(loadedImage: LoadedImage, cropper: CropperPosition, settings: CropperSettings, output: 'base64', maxSize: Dimensions): ImageCroppedEvent | null;
crop(cropperState: CropperState, output: 'blob'): Promise<ImageCroppedEvent> | null;
crop(cropperState: CropperState, output: 'base64'): ImageCroppedEvent | null;
private cropToBlob;

@@ -12,6 +11,4 @@ private getCanvasTranslate;

private getOffsetImagePosition;
getResizeRatio(width: number, height: number, settings: CropperSettings): number;
getQuality(settings: CropperSettings): number;
static ɵfac: i0.ɵɵFactoryDeclaration<CropService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<CropService>;
getResizeRatio(width: number, height: number, options: CropperOptions): number;
getQuality(options: CropperOptions): number;
}
import { LoadedImage } from '../interfaces';
import { CropperSettings } from '../interfaces/cropper.settings';
import * as i0 from "@angular/core";
import { CropperState } from '../component/cropper.state';
export declare class LoadImageService {
private autoRotateSupported;
loadImageFile(file: File, cropperSettings: CropperSettings): Promise<LoadedImage>;
loadImageFile(file: File, cropperSettings: CropperState): Promise<LoadedImage>;
private checkImageTypeAndLoadImageFromArrayBuffer;
private isValidImageType;
loadImageFromURL(url: string, cropperSettings: CropperSettings): Promise<LoadedImage>;
loadBase64Image(imageBase64: string, cropperSettings: CropperSettings): Promise<LoadedImage>;
loadImageFromURL(url: string, cropperSettings: CropperState): Promise<LoadedImage>;
loadBase64Image(imageBase64: string, cropperSettings: CropperState): Promise<LoadedImage>;
private base64ToArrayBuffer;

@@ -15,7 +14,5 @@ private loadImageFromArrayBuffer;

private transformImageFromArrayBuffer;
transformLoadedImage(loadedImage: Partial<LoadedImage>, cropperSettings: CropperSettings, forceTransform?: boolean): Promise<LoadedImage>;
transformLoadedImage(loadedImage: Partial<LoadedImage>, cropperState: CropperState, forceTransform?: boolean): Promise<LoadedImage>;
private loadImageFromObjectUrl;
private getTransformedSize;
static ɵfac: i0.ɵɵFactoryDeclaration<LoadImageService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<LoadImageService>;
}
import { BasicEvent } from "../interfaces/basic-event.interface";
export declare function getPositionForKey(key: string): string;
export declare function getInvertedPositionForKey(key: string): string;
import { Position } from "../interfaces/move-start.interface";
export declare function getPositionForKey(key: string): Position;
export declare function getInvertedPositionForKey(key: string): Position;
export declare function getEventForKey(key: string, stepSize: number): BasicEvent;
{
"name": "ngx-image-cropper",
"version": "8.0.0",
"version": "8.1.0",
"description": "An image cropper for Angular",

@@ -18,2 +18,3 @@ "author": "Martijn Willekens",

"angular 17",
"angular 18",
"ionic",

@@ -20,0 +21,0 @@ "ionic-angular",

@@ -76,37 +76,38 @@ # Image cropper for Angular

### Inputs
| Name | Type | Default | Description |
|----------------------------|--------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `imageChangedEvent` | FileEvent | | The change event from your file input (set to `null` to reset the cropper) |
| `imageFile` | Blob(File) | | The file you want to change (set to `null` to reset the cropper) |
| `imageBase64` | string | | If you don't want to use a file input, you can set a base64 image directly and it will be loaded into the cropper |
| `imageURL` | string | | If you don't want to use a file input or a base64 you can set an URL to get the image from. If requesting an image from a different domain make sure Cross-Origin Resource Sharing (CORS) is allowed or the image will fail to load. |
| `imageAltText` | string | | Alternative text for uploaded image for accessibility compliance. |
| `cropperFrameAriaLabel` | string | 'Crop photo' | Aria-label text for the focusable cropper frame element. |
| `format` | string | png | Output format (png, jpeg, webp, bmp, ico) (not all browsers support all types, png is always supported, others are optional) |
| `output` | string | blob | Output type (blob or base64) (blob is the most performant) |
| `aspectRatio` | number | 1 / 1 | The width / height ratio (e.g. 1 / 1 for a square, 4 / 3, 16 / 9 ...) |
| `maintainAspectRatio` | boolean | true | Keep width and height of cropped image equal according to the aspectRatio |
| `containWithinAspectRatio` | boolean | false | When set to true, padding will be added around the image to make it fit to the aspect ratio |
| `resizeToWidth` | number | 0 (disabled) | Cropped image will be resized to at most this width (in px) |
| `resizeToHeight` | number | 0 (disabled) | Cropped image will be resized to at most this height (in px) |
| `cropperStaticWidth` | number | 0 (disabled) | Set Cropper Width and disable resize (in px) |
| `cropperStaticHeight` | number | 0 (disabled) | Set Cropper Height and disable resize (in px) |
| `cropperMinWidth` | number | 0 (disabled) | The cropper cannot be made smaller than this number of pixels in width (relative to original image's size) (in px) |
| `cropperMinHeight` | number | 0 (disabled) | The cropper cannot be made smaller than this number of pixels in height (relative to original image's size) (in px) (will be ignored if `maintainAspectRatio` is set) |
| `cropperMaxWidth` | number | 0 (disabled) | The cropper cannot be made bigger than this number of pixels in width (in px) |
| `cropperMaxHeight` | number | 0 (disabled) | The cropper cannot be made bigger than this number of pixels in height (in px) |
| `initialStepSize` | number | 3 (px) | The initial step size in pixels when moving the cropper using the keyboard. Step size can then be changed by using the numpad when the cropper is focused |
| `onlyScaleDown` | boolean | false | When the `resizeToWidth` or `resizeToHeight` is set, enabling this option will make sure smaller images are not scaled up |
| `cropper` | CropperPosition | | To be able to overwrite the cropper coordinates, you can use this input. Create a new object of type `CropperPosition` and assign it to this input. Make sure to create a new object each time you wish to overwrite the cropper's position and wait for the `cropperReady` event to have fired. |
| `roundCropper` | boolean | false | Set this to true for a round cropper. Resulting image will still be square, use `border-radius: 100%` on resulting image to show it as round. |
| `imageQuality` | number | 92 | This only applies when using jpeg or webp as output format. Entering a number between 0 and 100 will determine the quality of the output image. |
| `autoCrop` | boolean | true | When set to true, the cropper will emit an image each time the position or size of the cropper is changed. When set to false, you can call the crop method yourself (use @ViewChild to get access to the croppers methods). |
| `alignImage` | 'left' or 'center' | 'center' | Use this to align the image in the cropper either to the left or center. |
| `backgroundColor` | string | | Use this to set a backgroundColor, this is useful if you upload an image of a format with transparent colors and convert it to 'jpeg' or 'bmp'. The transparent pixels will then become the set color or the default value. Enter any string representing a CSS color (https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). |
| `hideResizeSquares` | boolean | false | Disables the resize-squares at the border of the cropper. This is mostly useful for Touch Devices where you can change the Size of the Cropper via Pinch-To-Zoom |
| `disabled` | boolean | false | Disables the component and prevents changing the cropper position |
| `canvasRotation` | number | 0 | Rotate the canvas (1 = 90deg, 2 = 180deg...) |
| `transform` | ImageTransform | {} | Flip, rotate and scale image. (if `allowMoveImage` is enabled, make sure to use 2-way data binding `[(transform)]="transform"`. |
| `allowMoveImage` | boolean | false | Allow background image to be moved. When enabled and using the `transform` input, make sure to use 2-way data binding for the transform input (`[(transform)]="transform"`). |
| `hidden` | boolean | false | Set to true to hide image cropper |
| Name | Type | Default | Description |
|----------------------------|-------------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `imageChangedEvent` | FileEvent | | The change event from your file input (set to `null` to reset the cropper) |
| `imageFile` | Blob(File) | | The file you want to change (set to `null` to reset the cropper) |
| `imageBase64` | string | | If you don't want to use a file input, you can set a base64 image directly and it will be loaded into the cropper |
| `imageURL` | string | | If you don't want to use a file input or a base64 you can set an URL to get the image from. If requesting an image from a different domain make sure Cross-Origin Resource Sharing (CORS) is allowed or the image will fail to load. |
| `imageAltText` | string | | Alternative text for uploaded image for accessibility compliance. |
| `cropperFrameAriaLabel` | string | 'Crop photo' | Aria-label text for the focusable cropper frame element. |
| `format` | string | png | Output format (png, jpeg, webp, bmp, ico) (not all browsers support all types, png is always supported, others are optional) |
| `output` | string | blob | Output type (blob or base64) (blob is the most performant) |
| `aspectRatio` | number | 1 / 1 | The width / height ratio (e.g. 1 / 1 for a square, 4 / 3, 16 / 9 ...) |
| `maintainAspectRatio` | boolean | true | Keep width and height of cropped image equal according to the aspectRatio |
| `containWithinAspectRatio` | boolean | false | When set to true, padding will be added around the image to make it fit to the aspect ratio |
| `resizeToWidth` | number | 0 (disabled) | Cropped image will be resized to at most this width (in px) |
| `resizeToHeight` | number | 0 (disabled) | Cropped image will be resized to at most this height (in px) |
| `cropperStaticWidth` | number | 0 (disabled) | Set Cropper Width and disable resize (in px) |
| `cropperStaticHeight` | number | 0 (disabled) | Set Cropper Height and disable resize (in px) |
| `cropperMinWidth` | number | 0 (disabled) | The cropper cannot be made smaller than this number of pixels in width (relative to original image's size) (in px) |
| `cropperMinHeight` | number | 0 (disabled) | The cropper cannot be made smaller than this number of pixels in height (relative to original image's size) (in px) (will be ignored if `maintainAspectRatio` is set) |
| `cropperMaxWidth` | number | 0 (disabled) | The cropper cannot be made bigger than this number of pixels in width (in px) |
| `cropperMaxHeight` | number | 0 (disabled) | The cropper cannot be made bigger than this number of pixels in height (in px) |
| `initialStepSize` | number | 3 (px) | The initial step size in pixels when moving the cropper using the keyboard. Step size can then be changed by using the numpad when the cropper is focused |
| `onlyScaleDown` | boolean | false | When the `resizeToWidth` or `resizeToHeight` is set, enabling this option will make sure smaller images are not scaled up |
| `cropper` | CropperPosition | | To be able to overwrite the cropper coordinates, you can use this input. Create a new object of type `CropperPosition` and assign it to this input. Make sure to create a new object each time you wish to overwrite the cropper's position and wait for the `cropperReady` event to have fired. |
| `roundCropper` | boolean | false | Set this to true for a round cropper. Resulting image will still be square, use `border-radius: 100%` on resulting image to show it as round. |
| `imageQuality` | number | 92 | This only applies when using jpeg or webp as output format. Entering a number between 0 and 100 will determine the quality of the output image. |
| `autoCrop` | boolean | true | When set to true, the cropper will emit an image each time the position or size of the cropper is changed. When set to false, you can call the crop method yourself (use @ViewChild to get access to the croppers methods). |
| `alignImage` | 'left' or 'center' | 'center' | Use this to align the image in the cropper either to the left or center. |
| `backgroundColor` | string | | Use this to set a backgroundColor, this is useful if you upload an image of a format with transparent colors and convert it to 'jpeg' or 'bmp'. The transparent pixels will then become the set color or the default value. Enter any string representing a CSS color (https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). |
| `hideResizeSquares` | boolean | false | Disables the resize-squares at the border of the cropper. This is mostly useful for Touch Devices where you can change the Size of the Cropper via Pinch-To-Zoom |
| `disabled` | boolean | false | Disables the component and prevents changing the cropper position |
| `canvasRotation` | number | 0 | Rotate the canvas (1 = 90deg, 2 = 180deg...) |
| `transform` | ImageTransform | {} | Flip, rotate and scale image. (if `allowMoveImage` is enabled, make sure to use 2-way data binding `[(transform)]="transform"`. |
| `allowMoveImage` | boolean | false | Allow background image to be moved. When enabled and using the `transform` input, make sure to use 2-way data binding for the transform input (`[(transform)]="transform"`). |
| `hidden` | boolean | false | Set to true to hide image cropper |
| `options` | Partial<CropperOptions> | undefined | Provide more options at once instead of using the individual inputs. The options passed using this input will be applied as a patch. If you pass `{canvasRotation: 3}` and then `{}`, this will not reset the `canvasRotation`. To reset it, you should pass `{canvasRotation: 0}`. |

@@ -120,9 +121,11 @@ ### CSS Variables

### Outputs
| Name | Type | Description |
|-------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------|
| `imageCropped` | ImageCroppedEvent | Emits an ImageCroppedEvent each time the image is cropped |
| `imageLoaded` | LoadedImage | Emits the `LoadedImage` when it was loaded into the cropper |
| `cropperReady` | Dimensions | Emits when the cropper is ready to be interacted. The Dimensions object that is returned contains the displayed image size |
| `startCropImage` | void | Emits when the component started cropping the image |
| `loadImageFailed` | void | Emits when a wrong file type was selected (only png, gif and jpg are allowed) |
| Name | Type | Description |
|-------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `imageCropped` | ImageCroppedEvent | Emits an ImageCroppedEvent each time the image is cropped |
| `imageLoaded` | LoadedImage | Emits the `LoadedImage` when it was loaded into the cropper |
| `cropperReady` | Dimensions | Emits when the cropper is ready to be interacted. The Dimensions object that is returned contains the displayed image size |
| `startCropImage` | void | Emits when the component started cropping the image |
| `loadImageFailed` | void | Emits when a wrong file type was selected (only png, gif and jpg are allowed) |
| `transformChange` | ImageTransform | Emits when the image transformations changed. It can be used for 2-way data-binding because this object can be changed from outside as well as inside the component. |
| `cropperChange` | CropperPosition | Emits when the cropper position changed. It can be used for 2-way data-binding because this object can be changed from outside as well as inside the component. |

@@ -134,3 +137,3 @@ ### Methods

|----------------------------------------------------|-------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <code>crop(output?: 'blob' &#124; 'base64')</code> | Promise<ImageCroppedEvent> or ImageCroppedEvent | Crops the source image to the current cropper position. Be sure to set `autoCrop` to `false` if you only wish to use this function directly. When output is set to blob, a Promise will be returned. |
| <code>crop(output?: 'blob' &#124; 'base64')</code> | Promise<ImageCroppedEvent> or ImageCroppedEvent | Crops the source image to the current cropper position. Be sure to set `autoCrop` to `false` if you only wish to use this function directly. When output is set to `blob`, a Promise will be returned. |

@@ -137,0 +140,0 @@ ### Interfaces

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc