Gathering detailed insights and metrics for ng-img-editor
Gathering detailed insights and metrics for ng-img-editor
npm install ng-img-editor
Typescript
Module System
Node Version
NPM Version
69.2
Supply Chain
96.3
Quality
76
Maintenance
100
Vulnerability
98.9
License
JavaScript (96.99%)
CSS (3.01%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
3,818
Last Day
5
Last Week
13
Last Month
115
Last Year
1,149
1 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Apr 06, 2023
Minified
Minified + Gzipped
Latest Version
1.2.3
Package Id
ng-img-editor@1.2.3
Unpacked Size
232.86 kB
Size
50.76 kB
File Count
20
NPM Version
7.24.2
Node Version
14.19.3
Published on
Apr 06, 2023
Cumulative downloads
Total Downloads
Last Day
400%
5
Compared to previous day
Last Week
-56.7%
13
Compared to previous week
Last Month
113%
115
Compared to previous month
Last Year
-38.6%
1,149
Compared to previous year
2
2
ViewContainerRef
1 npm install ng-img-editor --save 2 3 or 4 5 yarn add ng-img-editor
1@import "~ng-img-editor/photo-editor.css";
"styles": [
"styles.scss",
"node_modules/ng-img-editor/photo-editor.css" // try adding '../' if you're using angular cli before 6
]
1import {NgModule} from '@angular/core'; 2import {BrowserModule} from '@angular/platform-browser'; 3import {AppComponent} from './app.component'; 4import {NgImgEditorModule} from "ng-img-editor"; 5 6@NgModule({ 7 declarations: [ 8 AppComponent 9 ], 10 imports: [ 11 BrowserModule, 12 NgImgEditorModule, 13 ], 14 providers: [], 15 bootstrap: [AppComponent] 16}) 17export class AppModule { 18} 19
1<input type="file" (change)="fileChangeHandler($event)"> 2<img [src]="output?.base64" alt="">
And add this to your .ts file:
1import {Component} from '@angular/core'; 2import {NgxCroppedEvent, NgImgEditorService} from "ng-img-editor"; 3 4@Component({...}) 5export class AppComponent { 6 output?: NgxCroppedEvent; 7 8 constructor(private service: NgImgEditorService) {} 9 10 fileChangeHandler($event: any) { 11 this.service.open($event, { 12 aspectRatio: 4 / 3, 13 autoCropArea: 1 14 }).subscribe(data => { 15 this.output = data; 16 }); 17 } 18}
You can pass any supported type of parameters to NgImgEditorService.open()
to open the cropper. After click Apply
button the observer will return an object with the cropped image as a Base64, Blob in its payload.
Name | Type | Description |
---|---|---|
source | `FileEvent | File |
options | check below para | This is an optional parameter |
Name | Type | Default | Description |
---|---|---|---|
format | string | source Image format | Output format (png, jpeg, webp, bmp, ico) (not all browsers support all types, png is always supported, others are optional) |
aspectRatio | number | NaN | The width / height ratio (e.g. 1 / 1 for a square, 4 / 3, 16 / 9 ...) |
resizeToWidth | number | 0 (disabled) | Cropped image will be resized to this width (in px) |
resizeToHeight | number | 0 (disabled) | Cropped image will be resized to this height (in px) |
roundCropper | boolean | false | Set this to true for a round cropper mask. 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 | Enable to crop the image automatically when initialized. |
autoCropArea | number | 1 (80% of the image) | A number between 0 and 1. Define the automatic cropping area size (percentage). |
viewMode | number | 0 | Define the ViewMode of the cropper. |
mask | boolean | true | Show the black modal above the image and under the crop box. |
guides | boolean | true | Show the dashed lines above the crop box. |
centerIndicator | boolean | true | Show the center indicator above the crop box. |
scalable | boolean | true | Enable to scale the image. |
zoomable | boolean | true | Enable to zoom the image. |
cropBoxMovable | boolean | true | Enable to move the crop box by dragging. |
cropBoxResizable | boolean | true | Enable to resize the crop box by dragging. |
imageSmoothingEnabled | boolean | true | Smooth image output. |
imageSmoothingQuality | string | low | quality of image smoothing, one of "low" or "medium", or "high". |
modalMaxWidth | string | '500px' | max-width property of the dialog container |
hideModalHeader | boolean | false | Hide Modal Header. |
applyBtnText | string | Apply | Apply button text |
closeBtnText | string | Close | Close button text |
Property | Type | Description |
---|---|---|
base64 | string | Base64 string of the cropped image |
file | file(Blob) | Blob(File) of the cropped image |
Number
0
0
: no restrictions1
: restrict the crop box to not exceed the size of the canvas.2
: restrict the minimum canvas size to fit within the container. If the proportions of the canvas and the container differ, the minimum canvas will be surrounded by extra space in one of the dimensions.3
: restrict the minimum canvas size to fill fit the container. If the proportions of the canvas and the container are different, the container will not be able to fit the whole canvas in one of the dimensions.Define the view mode of the cropper. If you set viewMode
to 0
, the crop box can extend outside the canvas, while a value of 1
, 2
or 3
will restrict the crop box to the size of the canvas. A viewMode
of 2
or 3
will additionally restrict the canvas to the container. Note that if the proportions of the canvas and the container are the same, there is no difference between 2
and 3
.
No vulnerabilities found.
No security vulnerabilities found.