Gathering detailed insights and metrics for ngx-dropzone-compressing
Gathering detailed insights and metrics for ngx-dropzone-compressing
A highly configurable dropzone component for Angular with compressing options
npm install ngx-dropzone-compressing
Typescript
Module System
Node Version
NPM Version
70.6
Supply Chain
97
Quality
76.2
Maintenance
100
Vulnerability
98.9
License
TypeScript (79.16%)
HTML (8.09%)
SCSS (6.28%)
JavaScript (6.07%)
CSS (0.4%)
Total Downloads
5,344
Last Day
12
Last Week
53
Last Month
194
Last Year
2,228
1 Stars
89 Commits
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.9.0
Package Id
ngx-dropzone-compressing@1.9.0
Unpacked Size
279.59 kB
Size
69.26 kB
File Count
28
NPM Version
8.19.3
Node Version
18.13.0
Publised On
21 Mar 2023
Cumulative downloads
Total Downloads
Last day
-29.4%
12
Compared to previous day
Last week
10.4%
53
Compared to previous week
Last month
21.3%
194
Compared to previous month
Last year
-28.5%
2,228
Compared to previous year
1
1
A lightweight and highly customizable Angular dropzone component for file uploads integrating file compression functionalities. This package is an extended version of ngx-dropzone created by Peter Freeman.
$ npm install --save ngx-dropzone-compressing
1// in app.module.ts 2import { NgxDropzoneModule } from 'ngx-dropzone-compressing'; 3 4@NgModule({ 5 ... 6 imports: [ 7 NgxDropzoneModule 8 ], 9 ... 10}) 11export class AppModule { }
1<!-- in app.component.html --> 2<ngx-dropzone (change)="onSelect($event)" [compress]="true"> 3 <ngx-dropzone-label>Drop it, baby!</ngx-dropzone-label> 4 <ngx-dropzone-preview *ngFor="let f of files" [removable]="true" (removed)="onRemove(f)"> 5 <ngx-dropzone-label>{{ f.name }} ({{ f.type }})</ngx-dropzone-label> 6 </ngx-dropzone-preview> 7</ngx-dropzone>
1// in app.component.ts 2files: File[] = []; 3 4onSelect(event) { 5 console.log(event); 6 this.files.push(...event.addedFiles); 7} 8 9onRemove(event) { 10 console.log(event); 11 this.files.splice(this.files.indexOf(event), 1); 12}
You can also use special preview components to preview images or videos:
1<ngx-dropzone-image-preview ngProjectAs="ngx-dropzone-preview" *ngFor="let f of files" [file]="f"> 2 <ngx-dropzone-label>{{ f.name }} ({{ f.type }})</ngx-dropzone-label> 3</ngx-dropzone-image-preview>
1<ngx-dropzone-video-preview ngProjectAs="ngx-dropzone-preview" *ngFor="let f of files" [file]="f"> 2 <ngx-dropzone-label>{{ f.name }} ({{ f.type }})</ngx-dropzone-label> 3</ngx-dropzone-video-preview>
This component is the actual dropzone container. It contains the label and any file previews. It has an event listener for file drops and you can also click it to open the native file explorer for selection.
Use it as a stand-alone component <ngx-dropzone></ngx-dropzone>
or by adding it as an attribute to a custom div
(<div class="custom-dropzone" ngx-dropzone></div>
).
It will add the classes ngx-dz-hovered
and ngx-dz-disabled
to its host element if necessary. You could override the styling of these effects if you like to.
This component has the following Input properties:
[compress]
: Allow the files compression.
false
.boolean
or CompressImageConfig
. Using just true
to default CompressImageConfig configuration.CompressImageConfig
:
Parameter | Type | Description |
---|---|---|
orientation | number | EXIF Orientation value using the DOC_ORIENTATION enum value(optional, default: -1) |
ratio | number | Maximum scale factor as a percentage (optional, default: 50) 1 |
quality | number | JPEG quality factor as a percentage (optional, default: 50) 2 |
maxWidth | number | Maximum width in pixels if you need to resize (optional, default: 0 - no resize) |
maxHeight | number | Maximum height in pixels if you need to resize (optional, default: 0 - no resize) |
[1] Ratio: "50" will decrease the resolution of each dimension by 2, i.e.: image of 2000 X 1500 pixels will become 1000 X 750 pixels, while the whole resolution will be reduced by 4. | ||
[2] Quality: For more info about this parameter, read this guide. |
[multiple]
: Allow the selection of multiple files at once. Defaults to true
.[accept]
: Set the accepted file types (as for a native file element). Defaults to '*'
. Example: [accept]="image/jpeg,image/jpg,image/png,image/gif"
[maxFileSize]
: Set the maximum size a single file may have, in bytes. Defaults to undefined
.[disabled]
: Disable any user interaction with the component. Defaults to false
.[expandable]
: Allow the dropzone container to expand vertically as the number of previewed files increases. Defaults to false
which means that it will allow for horizontal scrolling.[disableClick]
: Prevent the file selector from opening when clicking the dropzone.[id], [aria-label], [aria-labelledby]
, [aria-describedby]
: Forward the accessibility properties to the file input element.[processDirectoryDrop]
: Enable extracting files from dropped directories. Defaults to false
.It has the following Output event:
(change)
: Emitted when any files were added or rejected. It returns a NgxDropzoneChangeEvent
with the properties source: NgxDropzoneComponent
, addedFiles: File[]
and rejectedFiles: RejectedFile[]
.(onFileProcessing)
: Emitted when a file is trying to be processed. It returns a NgxDropzoneFileProcessingEvent
with the properties file: File
, remainingFilesNumber: number
.The RejectedFile
extends the native File and adds an optional reason property to tell you why the file was rejected. Its value will be either 'type'
for the wrong acceptance type, size
if it exceeds the maximum file size or no_multiple
if multiple is set to false and more than one file is provided.
If you'd like to show the native file selector programmatically then do it as follows:
1<ngx-dropzone #drop></ngx-dropzone> 2<button (click)="drop.showFileSelector()">Open</button>
This component has no attributes or methods and acts as a container for the label text using content projection. You can place anything inside of it and the text will always be centered.
This component shows a basic file preview when added inside the dropzone container. The previews can be focused using the tab key and be deleted using the backspace or delete keys.
This component has the following Input properties:
[file]
: The dropped file to preview.[removable]
: Allow the user to remove files. Required to allow keyboard interaction and show the remove badge on hover.It has the following Output event:
(removed)
: Emitted when the element should be removed (either by clicking the remove badge or by pressing backspace/delete keys). Returns the file from the Input property.The ngx-dropzone-image-preview
and ngx-dropzone-video-preview
components inherit from this component but expand the preview functionality to display either images or videos directly in the component. See the wiki on how to implement your own custom preview components.
This component is used within the previews to remove selected files. You can use it within your own preview component implementation if you like (see the wiki).
How to upload a file to a Web API?
MIT © TMCX
No vulnerabilities found.
No security vulnerabilities found.