react-native-compressor 1.6.1 → 1.6.2
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
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1 align="center">🗜️Compress Image, Video, and Audio same like Whatsapp <img height="30" src="/media/whatsapp_logo.png"></h1>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
### Why should we use react-native-compress over [FFmpeg](https://www.ffmpeg.org/)?
|
|
6
|
+
|
|
7
|
+
We should use **react-native-compressor** instead of **FFmpeg** because **react-native-compressor** gives you same compression **Whatsapp** (`Image, Video, and Audio`) without knowing the algorithm of compression + it is lightweight only increase **50 KB Size** Size in APK. While in **FFmpeg**, we have to give manual image/video/Audo size and quality as well as **FFmpeg** increase ~> **9 MB Size** in **APK**
|
|
8
|
+
|
|
1
9
|
### Would you like to support me?
|
|
2
10
|
|
|
3
11
|
<div align="center">
|
|
4
12
|
<a href="https://github.com/numandev1?tab=followers">
|
|
5
13
|
<img src="https://img.shields.io/github/followers/numandev1?label=Follow%20%40numandev1&style=social" height="36" />
|
|
6
14
|
</a>
|
|
15
|
+
<a href="https://twitter.com/numandev1/">
|
|
16
|
+
<img src="https://img.shields.io/twitter/follow/numandev1?label=Follow%20%40numandev1&style=social" height="36" />
|
|
17
|
+
</a>
|
|
7
18
|
<a href="https://www.youtube.com/channel/UCYCUspfN7ZevgCj3W5GlFAw"><img src="https://img.shields.io/youtube/channel/subscribers/UCYCUspfN7ZevgCj3W5GlFAw?style=social" height="36" /><a/>
|
|
8
19
|
</br>
|
|
9
20
|
<a href="https://www.buymeacoffee.com/numan.dev" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
|
|
@@ -11,17 +22,18 @@
|
|
|
11
22
|
|
|
12
23
|
---
|
|
13
24
|
|
|
14
|
-
# react-native-compressor
|
|
15
|
-
|
|
16
25
|
<!-- Header -->
|
|
17
26
|
|
|
18
27
|
<p align="center">
|
|
19
|
-
<
|
|
28
|
+
<h1>Banchmark between <img height="50" src="/media/whatsapp_logo.png"> VS REACT-NATIVE-COMPRESSOR</h1>
|
|
20
29
|
<br />
|
|
21
30
|
</p>
|
|
22
31
|
|
|
32
|
+
|
|
23
33
|
<p align="center">
|
|
24
|
-
<img height="450" src="/media/
|
|
34
|
+
<img height="450" src="/media/branchmark_for_images.png">
|
|
35
|
+
<br /> <br />
|
|
36
|
+
<img height="450" src="/media/benchmark_for_videos.png">
|
|
25
37
|
</p>
|
|
26
38
|
|
|
27
39
|
**react-native-compressor** package is a set of functions that allow you compress `Image`,`Audio` and `Video`
|
|
@@ -395,7 +407,7 @@ if you want to convert
|
|
|
395
407
|
- `content://` to `file:///` for android
|
|
396
408
|
- `ph://` to `file:///` for IOS
|
|
397
409
|
|
|
398
|
-
|
|
410
|
+
then you can call `getRealPath` function like this
|
|
399
411
|
|
|
400
412
|
```js
|
|
401
413
|
import { getRealPath } from 'react-native-compressor';
|
|
@@ -42,14 +42,14 @@ public class Utils {
|
|
|
42
42
|
@Override
|
|
43
43
|
public void onFinish(boolean result) {
|
|
44
44
|
//convert finish,result(true is success,false is fail)
|
|
45
|
-
promise.resolve("file
|
|
45
|
+
promise.resolve("file://"+destinationPath);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@Override
|
|
49
49
|
public void onError(String errorMessage) {
|
|
50
50
|
if(errorMessage.equals(("class java.lang.AssertionError")))
|
|
51
51
|
{
|
|
52
|
-
promise.resolve(srcPath);
|
|
52
|
+
promise.resolve("file://"+srcPath);
|
|
53
53
|
}
|
|
54
54
|
else
|
|
55
55
|
{
|
|
@@ -110,4 +110,14 @@ public class VideoModule extends ReactContextBaseJavaModule {
|
|
|
110
110
|
promise.reject(ex);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
public void addListener(String eventName) {
|
|
116
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@ReactMethod
|
|
120
|
+
public void removeListeners(Integer count) {
|
|
121
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
122
|
+
}
|
|
113
123
|
}
|
|
@@ -319,7 +319,7 @@ func makeValidUri(filePath: String) -> String {
|
|
|
319
319
|
var width = Float(abs(videoSize.width))
|
|
320
320
|
var height = Float(abs(videoSize.height))
|
|
321
321
|
let isPortrait = height > width
|
|
322
|
-
let maxSize = Float(1920);
|
|
322
|
+
let maxSize = (options["maxSize"] as! Float?) ?? Float(1920);
|
|
323
323
|
if(isPortrait && height > maxSize){
|
|
324
324
|
width = (maxSize/height)*width
|
|
325
325
|
height = maxSize
|