Installations
npm install ngx-photo-editor
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
No
Node Version
16.14.2
NPM Version
8.6.0
Statistics
25 Stars
71 Commits
26 Forks
3 Watching
12 Branches
1 Contributors
Updated on 10 Sept 2024
Bundle Size
67.62 kB
Minified
17.78 kB
Minified + Gzipped
Languages
TypeScript (46.82%)
HTML (33.24%)
CSS (11.54%)
JavaScript (7.78%)
SCSS (0.63%)
Total Downloads
Cumulative downloads
Total Downloads
179,050
Last day
11.2%
287
Compared to previous day
Last week
10.5%
1,728
Compared to previous week
Last month
-5.4%
7,037
Compared to previous month
Last year
46.5%
74,475
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
2
Image Cropper for Angular
Demo
Features
- NgxPhotoEditor Component Injection without being passed
ViewContainerRef
- High performance
- Highly configurable and customizable
- Overridable styles
- Fully Supported
Install
1 npm install ngx-photo-editor --save
Setup
Step 1:
- Import CSS.
1@import "~ngx-photo-editor/photo-editor.css";
- If you are using angular-cli you can add it to your angular.json
"styles": [
"styles.scss",
"node_modules/ngx-photo-editor/photo-editor.css" // try adding '../' if you're using angular cli before 6
]
Step 2:
- Add NgxPhotoEditorModule to app.module.ts
1import {NgModule} from '@angular/core'; 2import {BrowserModule} from '@angular/platform-browser'; 3import {AppComponent} from './app.component'; 4import {NgxPhotoEditorModule} from "ngx-photo-editor"; 5 6@NgModule({ 7 declarations: [ 8 AppComponent 9 ], 10 imports: [ 11 BrowserModule, 12 NgxPhotoEditorModule, 13 ], 14 providers: [], 15 bootstrap: [AppComponent] 16}) 17export class AppModule { 18} 19
Usage
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, NgxPhotoEditorService} from "ngx-photo-editor"; 3 4@Component({...}) 5export class AppComponent { 6 output?: NgxCroppedEvent; 7 8 constructor(private service: NgxPhotoEditorService) {} 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 NgxPhotoEditorService.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.
Parameters
Name | Type | Description |
---|---|---|
source | `FileEvent | File |
options | check below para | This is an optional parameter |
Options
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 |
Interfaces
NgxCroppedEvent
Property | Type | Description |
---|---|---|
base64 | string | Base64 string of the cropped image |
file | file(Blob) | Blob(File) of the cropped image |
viewMode
- Type:
Number
- Default:
0
- Options:
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.
Reason
no binaries found in the repo
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
37 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w
- Warn: Project is vulnerable to: GHSA-q9mw-68c2-j6m5
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
1.5
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to ngx-photo-editor
ngx-editor
The Rich Text Editor for Angular, Built on ProseMirror
ngx-quill
Angular components for the easy use of the QuillJS richt text editor.
ngx-webcam
A simple Angular webcam component. Pure & minimal, no Flash-fallback. <a href="https://basst314.github.io/ngx-webcam/?" target="_blank">See the Demo!</a>
ngx-monaco-editor-v2
Monaco Code Editor for Angular