compressorjs 1.1.0 → 1.2.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/README.md +13 -4
- package/dist/compressor.common.js +515 -597
- package/dist/compressor.esm.js +515 -597
- package/dist/compressor.js +515 -597
- package/dist/compressor.min.js +3 -3
- package/package.json +29 -29
- package/src/defaults.js +6 -0
- package/src/index.js +82 -24
- package/src/utilities.js +61 -0
- package/types/index.d.ts +1 -0
- package/CHANGELOG.md +0 -44
- package/dist/compressor.common.js.map +0 -1
- package/dist/compressor.esm.js.map +0 -1
- package/dist/compressor.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Compressor.js
|
|
2
2
|
|
|
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)
|
|
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 [canvas.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) API to do the compression work, which means it is **lossy compression**, **asynchronous**, and has **different compression effects in different browsers**.
|
|
5
|
+
> JavaScript image compressor. Uses the Browser's native [canvas.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) API 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
|
|
|
@@ -94,6 +94,7 @@ document.getElementById('file').addEventListener('change', (e) => {
|
|
|
94
94
|
console.log(err.message);
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
|
+
|
|
97
98
|
});
|
|
98
99
|
```
|
|
99
100
|
|
|
@@ -109,8 +110,9 @@ If you want to change the global default options, You may use `Compressor.setDef
|
|
|
109
110
|
- Type: `boolean`
|
|
110
111
|
- Default: `true`
|
|
111
112
|
|
|
112
|
-
Indicates
|
|
113
|
+
Indicates whether to output the original image instead of the compressed one when the size of the compressed image is greater than the original one's, except the following cases:
|
|
113
114
|
|
|
115
|
+
- The `retainExif` option is set to `true`.
|
|
114
116
|
- The `mimeType` option is set and its value is different from the mime type of the image.
|
|
115
117
|
- The `width` option is set and its value is greater than the natural width of the image.
|
|
116
118
|
- The `height` option is set and its value is greater than the natural height of the image.
|
|
@@ -124,7 +126,7 @@ Indicates if output the original image instead of the compressed one when the si
|
|
|
124
126
|
- Type: `boolean`
|
|
125
127
|
- Default: `true`
|
|
126
128
|
|
|
127
|
-
Indicates
|
|
129
|
+
Indicates whether to read the image's Exif Orientation value (JPEG image only), and then rotate or flip the image automatically with the value.
|
|
128
130
|
|
|
129
131
|
**Notes:**
|
|
130
132
|
|
|
@@ -132,6 +134,13 @@ Indicates if read the image's Exif Orientation value (JPEG image only), and then
|
|
|
132
134
|
- If the size of the target image is too large (e.g., greater than 10 MB), you should disable this option to avoid an out-of-memory crash.
|
|
133
135
|
- The image's Exif information will be removed after compressed, so if you need the Exif information, you may need to upload the original image as well.
|
|
134
136
|
|
|
137
|
+
### retainExif
|
|
138
|
+
|
|
139
|
+
- Type: `boolean`
|
|
140
|
+
- Default: `false`
|
|
141
|
+
|
|
142
|
+
Indicates whether to retain the image's Exif information after compressed.
|
|
143
|
+
|
|
135
144
|
### maxWidth
|
|
136
145
|
|
|
137
146
|
- Type: `number`
|