Gathering detailed insights and metrics for @digitalascetic/ngx-pica
Gathering detailed insights and metrics for @digitalascetic/ngx-pica
Gathering detailed insights and metrics for @digitalascetic/ngx-pica
Gathering detailed insights and metrics for @digitalascetic/ngx-pica
npm install @digitalascetic/ngx-pica
Typescript
Module System
Node Version
NPM Version
61.6
Supply Chain
95.9
Quality
87.9
Maintenance
100
Vulnerability
98.9
License
TypeScript (93.78%)
JavaScript (6.22%)
Total Downloads
272,256
Last Day
74
Last Week
352
Last Month
2,977
Last Year
48,331
36 Stars
107 Commits
26 Forks
6 Watching
4 Branches
5 Contributors
Latest Version
20.1.3
Package Id
@digitalascetic/ngx-pica@20.1.3
Unpacked Size
67.93 kB
Size
14.07 kB
File Count
16
NPM Version
10.2.3
Node Version
18.19.0
Publised On
16 Dec 2024
Cumulative downloads
Total Downloads
Last day
-8.6%
74
Compared to previous day
Last week
-49.6%
352
Compared to previous week
Last month
-16.5%
2,977
Compared to previous month
Last year
-17.7%
48,331
Compared to previous year
1
3
@digitalascetic/ngx-pica is an Angular (LTS) module to resize images files in browser using pica - high quality image resize in browser.
@digitalascetic/ngx-pica Angular 5 compatibility is under version 1.1.8
1$ npm install @digitalascetic/ngx-pica@1.1.8 --save
ngx-pica
module as dependency to your project.1$ npm install pica exifr @digitalascetic/ngx-pica --save
NgxPicaModule
into your main AppModule or in module where you will use it.// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxPicaModule } from '@digitalascetic/ngx-pica';
@NgModule({
imports: [
BrowserModule,
NgxPicaModule
],
declarations: [ AppComponent ],
exports: [ AppComponent ]
})
export class AppModule {}
.resizeImages(files: File[], width: number, height: number, options?: NgxPicaResizeOptionsInterface): Observable<File>
This method resize an array of images doing it sequentially to optimize CPU and memory use.
The Observable receives a next on every file that has been resized. If something goes wrong the Observable receive an error.
All errors are wrapped by NgxPicaErrorInterface.
.resizeImage(file: File, width: number, height: number, options?: NgxPicaResizeOptionsInterface): Observable<File>
Same as above but only takes one file instead of an array of files.
.compressImages(files: File[], sizeInMB: number): Observable<File>
This method compress an array of images doing it sequentially to optimize CPU and memory use.
The Observable receives a next on every file that has been resized. If something goes wrong the Observable receive an error.
All errors are wrapped by NgxPicaErrorInterface.
.compressImage(file: File, sizeInMB: number): Observable<File>
Same as above but only takes one file instead of an array of files.
.isImage(file: File): boolean
This method check if a file is an image or not
export interface AspectRatioOptions {
keepAspectRatio: boolean;
forceDimensions?: boolean;
}
export interface NgxPicaResizeOptionsInterface {
aspectRatio?: AspectRatioOptions;
quality?: number;
alpha?: boolean;
unsharpAmount?: number;
unsharpRadius?: number;
unsharpThreshold?: number;
}
export enum NgxPicaErrorType {
NO_FILES_RECEIVED = 'NO_FILES_RECEIVED',
CANVAS_CONTEXT_IDENTIFIER_NOT_SUPPORTED = 'CANVAS_CONTEXT_IDENTIFIER_NOT_SUPPORTED',
NOT_BE_ABLE_TO_COMPRESS_ENOUGH = 'NOT_BE_ABLE_TO_COMPRESS_ENOUGH'
}
export interface NgxPicaErrorInterface {
err: NgxPicaErrorType;
file?: File;
}
1import { Component, EventEmitter } from '@angular/core';
2import { NgxPicaService } from '@digitalascetic/ngx-pica';
3
4@Component({
5 selector: 'app-home',
6 template: `
7 <img *ngFor="let image of images" [src]="image" />
8
9 <input type="file" [attr.accept]="image/*" multiple
10 (change)="handleFiles($event)">
11 `
12})
13export class AppHomeComponent {
14 images: File[] = [];
15
16 constructor(private _ngxPicaService: NgxPicaService) {
17
18 }
19
20 public handleFiles(event: any) {
21 const files: File[] = event.target.files;
22
23 this._ngxPicaService.resizeImages(files, 1200, 880)
24 .subscribe((imageResized: File) => {
25 let reader: FileReader = new FileReader();
26
27 reader.addEventListener('load', (event: any) => {
28 this.images.push(event.target.result);
29 }, false);
30
31 reader.readAsDataURL(imageResized);
32
33 }, (err: NgxPicaErrorInterface) => {
34 throw err.err;
35 });
36 }
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 0/7 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-30
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 More