You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-47Lines changed: 44 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,10 @@ Javascript module to be run in the web browser for image compression.
8
8
## Features ##
9
9
- 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.
10
10
-**Multi-thread** (web worker) non-blocking compression are supported through options.
11
+
## Demo / Example ##
12
+
open https://donaldcwl.github.io/browser-image-compression/example/basic.html
11
13
14
+
or check the "[example]" folder in this repo
12
15
## Install ##
13
16
You can download imageCompression from the [dist folder][dist]. Alternatively, you can install it via yarn or npm
If this project help you reduce time to develop, you can buy me a cup of coffee :)
28
-
29
-
<ahref="https://www.buymeacoffee.com/donaldcwl"target="_blank"><imgsrc="https://cdn.buymeacoffee.com/buttons/v2/default-red.png"alt="Buy Me A Coffee"height=60width=217 ></a>
maxWidthOrHeight: number, // compressedFile will scale down by ratio to a point that width or height is smaller than maxWidthOrHeight (default: undefined)
55
-
// but, automatically reduce the size to smaller than the maximum Canvas size supported by each browser.
56
-
// Please check the Caveat part for details.
57
-
onProgress:Function, // optional, a function takes one progress argument (percentage from 0 to 100)
58
-
useWebWorker: boolean, // optional, use multi-thread web worker, fallback to run in main-thread (default: true)
59
-
60
-
// following options are for advanced users
61
-
maxIteration: number, // optional, max number of iteration to compress the image (default: 10)
62
-
exifOrientation: number, // optional, see https://stackoverflow.com/a/32490603/10395024
63
-
fileType: string, // optional, fileType override
64
-
initialQuality: number // optional, initial quality value between 0 and 1 (default: 1)
@@ -139,10 +98,48 @@ function handleImageUpload(event) {
139
98
}
140
99
```
141
100
142
-
## Demo / Example ##
143
-
open https://donaldcwl.github.io/browser-image-compression/example/basic.html
101
+
## Support
102
+
If this project help you reduce time to develop, you can buy me a cup of coffee :)
144
103
145
-
or check the "[example]" folder in this repo
104
+
<ahref="https://donaldcwl.github.io/donation/"target="_blank"><imgsrc="https://cdn.buymeacoffee.com/buttons/v2/default-red.png"alt="Buy Me A Coffee"height=60width=217 ></a>
105
+
## API ##
106
+
### Main function ###
107
+
```javascript
108
+
// you should provide one of maxSizeMB, maxWidthOrHeight in the options
maxWidthOrHeight: number, // compressedFile will scale down by ratio to a point that width or height is smaller than maxWidthOrHeight (default: undefined)
112
+
// but, automatically reduce the size to smaller than the maximum Canvas size supported by each browser.
113
+
// Please check the Caveat part for details.
114
+
onProgress:Function, // optional, a function takes one progress argument (percentage from 0 to 100)
115
+
useWebWorker: boolean, // optional, use multi-thread web worker, fallback to run in main-thread (default: true)
116
+
117
+
// following options are for advanced users
118
+
maxIteration: number, // optional, max number of iteration to compress the image (default: 10)
119
+
exifOrientation: number, // optional, see https://stackoverflow.com/a/32490603/10395024
120
+
fileType: string, // optional, fileType override
121
+
initialQuality: number // optional, initial quality value between 0 and 1 (default: 1)
0 commit comments