Installations
npm install @digitalascetic/ngx-pica
Developer Guide
Typescript
No
Module System
ESM
Node Version
18.19.0
NPM Version
10.2.3
Score
61.6
Supply Chain
95.9
Quality
87.9
Maintenance
100
Vulnerability
98.9
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (93.78%)
JavaScript (6.22%)
Developer
digitalascetic
Download Statistics
Total Downloads
272,256
Last Day
74
Last Week
352
Last Month
2,977
Last Year
48,331
GitHub Statistics
36 Stars
107 Commits
26 Forks
6 Watching
4 Branches
5 Contributors
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
272,256
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
3
@digitalascetic/ngx-pica
@digitalascetic/ngx-pica is an Angular (LTS) module to resize images files in browser using pica - high quality image resize in browser.
Important
@digitalascetic/ngx-pica Angular 5 compatibility is under version 1.1.8
1$ npm install @digitalascetic/ngx-pica@1.1.8 --save
Install
- Add
ngx-pica
module as dependency to your project.
1$ npm install pica exifr @digitalascetic/ngx-pica --save
- Include
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 {}
Services
- NgxPicaService - Manipulate images using pica - high quality image resize in browser
- NgxPicaImageService - Supplementary services to help you work with images
NgxPicaService Methods
.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.
- files:[] - Array of images to resize
- width - Width to be resized (px)
- height - Height to be resized (px)
- options - Based on pica - resize options, we've also added aspect ratio options:
- keepAspectRatio - Set true to ensure the aspect ratio of the image is maintained as it get resized
- forceMinDimensions - Set true to ensure the dimensions of image resized will be greater than width and height values defined
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.
- files:[] - Array of images to resize
- sizeInMB - File size in MegaBytes
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.
NgxPicaImageService Methods
.isImage(file: File): boolean
This method check if a file is an image or not
Data Structures
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;
}
Example
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
- 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
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 26 are checked with a SAST tool
Score
2.7
/10
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