compressorjs 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +12 -7
- package/dist/compressor.common.js +556 -445
- package/dist/compressor.esm.js +556 -445
- package/dist/compressor.js +556 -445
- package/dist/compressor.min.js +3 -3
- package/package.json +44 -39
- package/src/index.js +35 -14
- package/src/utilities.js +47 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright 2018-present Chen Fengyuan
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright 2018-present Chen Fengyuan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://codecov.io/gh/fengyuanchen/compressorjs) [](https://www.npmjs.com/package/compressorjs) [](https://www.npmjs.com/package/compressorjs) [](https://unpkg.com/compressorjs/dist/compressor.common.js)
|
|
4
4
|
|
|
5
|
-
> JavaScript image compressor. Uses the Browser's native [
|
|
5
|
+
> JavaScript image compressor. Uses the Browser's native [HTMLCanvasElement.toBlob()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) method to do the compression work, which means it is **lossy compression**, **asynchronous**, and has **different compression effects in different browsers**. Generally use this to precompress a image on the client side before uploading it.
|
|
6
6
|
|
|
7
7
|
- [Website](https://fengyuanchen.github.io/compressorjs)
|
|
8
8
|
|
|
9
9
|
## Table of contents
|
|
10
10
|
|
|
11
|
-
- [Main](#main)
|
|
11
|
+
- [Main Files](#main-files)
|
|
12
12
|
- [Getting started](#getting-started)
|
|
13
13
|
- [Options](#options)
|
|
14
14
|
- [Methods](#methods)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
- [Versioning](#versioning)
|
|
19
19
|
- [License](#license)
|
|
20
20
|
|
|
21
|
-
## Main
|
|
21
|
+
## Main Files
|
|
22
22
|
|
|
23
23
|
```text
|
|
24
24
|
dist/
|
|
@@ -204,7 +204,7 @@ The quality of the output image. It must be a number between `0` and `1`. If thi
|
|
|
204
204
|
|
|
205
205
|
**Note:** This option only available for `image/jpeg` and `image/webp` images.
|
|
206
206
|
|
|
207
|
-
> Check out [
|
|
207
|
+
> Check out the documentation of the [HTMLCanvasElement.toBlob()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) method for more detail.
|
|
208
208
|
|
|
209
209
|
**Examples**:
|
|
210
210
|
|
|
@@ -222,19 +222,24 @@ The quality of the output image. It must be a number between `0` and `1`. If thi
|
|
|
222
222
|
|
|
223
223
|
- Type: `string`
|
|
224
224
|
- Default: `'auto'`
|
|
225
|
+
- Options: `"auto"`, `"image/png"`, `"image/jpeg"`, and `"image/webp"`.
|
|
225
226
|
|
|
226
227
|
The mime type of the output image. By default, the original mime type of the source image file will be used.
|
|
227
228
|
|
|
229
|
+
> **Note:** Safari does not support `mimeType` conversion to `"image/webp"`. For more details, see the [browser compatibility of the `HTMLCanvasElement.toBlob()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility).
|
|
230
|
+
|
|
228
231
|
### convertTypes
|
|
229
232
|
|
|
230
233
|
- Type: `Array` or `string` (multiple types should be separated by commas)
|
|
231
|
-
- Default: `[
|
|
234
|
+
- Default: `["image/png"]`
|
|
232
235
|
- Examples:
|
|
233
|
-
- `[
|
|
234
|
-
- `
|
|
236
|
+
- `["image/png", "image/webp"]`
|
|
237
|
+
- `"image/png,image/webp"`
|
|
235
238
|
|
|
236
239
|
Files whose file type is included in this list, and whose file size exceeds the `convertSize` value will be converted to JPEGs.
|
|
237
240
|
|
|
241
|
+
> For image file type support, see the [Image file type and format guide](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types).
|
|
242
|
+
|
|
238
243
|
### convertSize
|
|
239
244
|
|
|
240
245
|
- Type: `number`
|