# ngx-m-img-cropper

> mobile image crop

Latest version **8.0.2** (published 2020-01-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-m-img-cropper
pnpm add ngx-m-img-cropper
yarn add ngx-m-img-cropper
bun add ngx-m-img-cropper
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.2 |
| Published | 2020-01-19 |
| First published | 2018-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 395.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | lichangfeng |
| Maintainers | heixia2025 |
| Keywords | angular, mobile, img crop, image crop, mobile crop |

## Links

- npm: https://www.npmjs.com/package/ngx-m-img-cropper
- Repository: https://github.com/lichangfeng/ngx-m-img-cropper
- Issues: https://github.com/lichangfeng/ngx-m-img-cropper/issues
- npm.io page: https://npm.io/package/ngx-m-img-cropper

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 8.0.2 (latest) — 2020-01-19
- 8.0.1 — 2020-01-19
- 0.0.7 — 2018-12-10
- 0.0.6 — 2018-09-06
- 0.0.5 — 2018-09-06
- 0.0.4 — 2018-09-06
- 0.0.3 — 2018-09-06
- 0.0.2 — 2018-09-06
- 0.0.1 — 2018-09-06

## README

# ngx-m-img-cropper - Angular Mobile Image Crop

## Demo
[Live Demo](https://lichangfeng.github.io/ngx-m-img-cropper/)
![avatar](https://lichangfeng.github.io/ngx-m-img-cropper/assets/demo_qrcode.png)

## Dependencies
* [Angular](https://angular.io) (*requires* Angular 8 or higher, tested with 8.0.3)
* [hammerjs](http://hammerjs.github.io/) (*requires* 2.0.8 or higher)

## Installation

```shell
npm i hammerjs
npm i ngx-m-img-cropper
```

import hammerjs in main.ts
```
import 'hammerjs';
```

Once installed you need to import the main module:
```js
import {ImgCropperModule} from 'ngx-m-img-cropper';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [ImgCropperModule, ...],  
  bootstrap: [AppComponent]
})
export class AppModule {
}
```
the cropped image 's background color is green, you can change it by provide a MCropParams
```js
 providers: [
    {provide: MCropParams, useValue: {backgroundColor: '#f0f0f0'}}, ...
  ]
```

add the m-img-cropper componet to your app.component.html
```js
<m-img-cropper></m-img-cropper>
```

## Usage

use it like this:
```js
import { Component, OnInit } from '@angular/core';
import {ImgCropperService} from 'ngx-m-img-cropper';

@Component({
  selector: '...',
  templateUrl: '...',
  styleUrls: ['...']
})
export class Mine1Component implements OnInit {

  imgsrc = 'assets/header.jpg';
  constructor(private imgCropperService: ImgCropperService) { }

  ngOnInit() {
  }
  click(): void {
    this.imgCropperService.getCropImgData({width: 400, height: 300})
      .then(data => {
        this.imgsrc = data;
      });
  }
```


## License

MIT License (MIT)

end

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