|
1 | 1 | # Browser Image Compression # |
2 | 2 | [](https://www.npmjs.com/package/browser-image-compression) |
3 | | -[](https://www.npmjs.com/package/browser-image-compression) |
| 3 | +[](https://github.com/Donaldcwl/browser-image-compression) |
4 | 4 |
|
5 | 5 | Javascript module to be run in the web browser for image compression. |
6 | | -You can use this module to compress jpeg and png image by reducing **resolution** or **storage size** before uploading to application server to save bandwidth. |
| 6 | + |
| 7 | +## Features ## |
| 8 | +- You can use this module to compress jpeg and png image by reducing **resolution** or **storage size** before uploading to application server to save bandwidth. |
7 | 9 |
|
8 | 10 | ## Install ## |
| 11 | +You can download imageCompression from the [dist folder][dist]. Alternatively, you can install it via yarn or npm |
9 | 12 | ``` |
10 | 13 | npm install browser-image-compression --save |
11 | 14 | or |
12 | 15 | yarn add browser-image-compression |
13 | 16 | ``` |
| 17 | +or use a CDN like [delivrjs]: |
| 18 | +``` |
| 19 | +https://cdn.jsdelivr.net/npm/browser-image-compression@0.0.4/dist/browser-image-compression.js |
| 20 | +``` |
14 | 21 |
|
15 | 22 | ## How to use this module in your project? ## |
16 | 23 | #### Use as ES module #### |
17 | 24 |
|
18 | 25 | (can be used in framework like React, Angular, Vue etc) |
19 | 26 |
|
20 | 27 | (work with bundler like webpack and rollup) |
21 | | -```javascript |
| 28 | +```javascriptx |
22 | 29 | import imageCompression from 'browser-image-compression'; |
23 | 30 | ``` |
24 | 31 |
|
25 | 32 | or |
26 | 33 |
|
27 | 34 | #### In html file #### |
28 | 35 | ```html |
29 | | -<script type="text/javascript" src="path/to/dist/browser-image-compression.js"></script> |
| 36 | +<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/browser-image-compression@0.0.4/dist/browser-image-compression.js"></script> |
30 | 37 | ``` |
31 | 38 |
|
32 | 39 | ## API ## |
@@ -93,4 +100,14 @@ async function handleImageUpload(event) { |
93 | 100 | | IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions| last 2 versions |
94 | 101 |
|
95 | 102 | ## Example ## |
96 | | -Please check the "example" folder in this repo |
| 103 | +Please check the "[example]" folder in this repo |
| 104 | +- How to run the example: |
| 105 | +```bash |
| 106 | +git clone https://github.com/Donaldcwl/browser-image-compression.git |
| 107 | +cd browser-image-compression/example |
| 108 | +# open "basic.html" on your browser |
| 109 | +``` |
| 110 | + |
| 111 | +[dist]: https://github.com/Donaldcwl/browser-image-compression/tree/master/dist |
| 112 | +[example]: https://github.com/Donaldcwl/browser-image-compression/tree/master/example |
| 113 | +[delivrjs]: https://cdn.jsdelivr.net/ |
0 commit comments