![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@fdezromero/ngx-pica
Advanced tools
@digitalascetic/ngx-pica is an Angular 5 module to resize images files in browser using pica - high quality image resize in browser.
ngx-pica
module as dependency to your project.$ npm install @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 '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;
}
import { Component, EventEmitter } from '@angular/core';
import { NgxPicaService } from 'ngx-pica';
@Component({
selector: 'app-home',
template: `
<img *ngFor="let image of images" [src]="image" />
<input type="file" [attr.accept]="image/*" multiple
(change)="handleFiles($event)">
`
})
export class AppHomeComponent {
images: File[] = [];
constructor(private _ngxPicaService: NgxPicaService) {
}
public handleFiles(event: any) {
const files: File[] = event.target.files;
this._ngxPicaService.resizeImages(files, 1200, 880)
.subscribe((imageResized: File) => {
let reader: FileReader = new FileReader();
reader.addEventListener('load', (event: any) => {
this.images.push(event.target.result);
}, false);
reader.readAsDataURL(imageResized);
}, (err: NgxPicaErrorInterface) => {
throw err.err;
});
}
FAQs
Angular 6 module to resize images files in browser
The npm package @fdezromero/ngx-pica receives a total of 1 weekly downloads. As such, @fdezromero/ngx-pica popularity was classified as not popular.
We found that @fdezromero/ngx-pica demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.