# ngx-image-compressor

> A utility for compressing images to a proper managable size/quality. Has simplified interface of ngx-image-compress library.

Latest version **1.0.6** (published 2020-08-07) · Onlife license · 0 weekly downloads

## Install

```sh
npm install ngx-image-compressor
pnpm add ngx-image-compressor
yarn add ngx-image-compressor
bun add ngx-image-compressor
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-08-07 |
| First published | 2020-08-06 |
| Weekly downloads | 0 |
| License | Onlife |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 155.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eugene Goryachkin |
| Maintainers | mr4pson |
| Keywords | angular, javascript, typescript, file compressor, image compressor |

## Links

- npm: https://www.npmjs.com/package/ngx-image-compressor
- npm.io page: https://npm.io/package/ngx-image-compressor

## Dependencies (1)

- [ngx-image-compress](https://npm.io/package/ngx-image-compress.md) ^8.0.4

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-08-07
- 1.0.5 — 2020-08-06
- 1.0.4 — 2020-08-06
- 1.0.2 — 2020-08-06
- 1.0.1 — 2020-08-06

## README

# ngx-image-compressor

A utility for compressing images to a proper managable size/quality. Has simplified interface of ngx-image-compress library.

### import
    npm i ngx-image-compressor

### Usage
Import it in your app module

```javascript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { NgxImageCompressorModule } from 'ngx-image-compressor';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, NgxImageCompressorModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
```

Use it in your component

```javascript
import { Component } from '@angular/core';
import { NgxImageCompressService, CompressorConfig } from 'ngx-image-compressor';

@Component({
  selector: 'app-root',
  template: `
    <div>
        <input type="file"  (change)="onChange($event)" accept="image/*" multiple />
    </div>
  `
})
export class AppComponent {
  constructor(private imageCompressor: ImageCompressorService) { }
  public onChange(event: any): void {
    const rawFiles: File[] = [].slice.call(event.target.files);
    rawFiles.forEach(async (file: File) => {
      const config: CompressorConfig = { orientation: 1, ratio: 50, quality: 50, enableLogs: true };
      const compressedFile: File = await this.imageCompressor.compressFile(file, config);
      console.log(compressedFile);
    });
  }
}
```

## Running unit tests

Run `nx test ngx-image-compressor` to execute the unit tests.

---
_Source: https://npm.io/package/ngx-image-compressor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
