react-native-compressor 1.6.1 โ†’ 1.6.3

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,30 @@
1
+ <div align="center">
2
+ <img height="150" src="/media/logo.png"></h2>
3
+ </div>
4
+ <br/>
5
+
6
+ **REACT-NATIVE-COMPRESSOR** is a react-native package, which help us to Compress `Image`, `Video`, and `Audio` same like **Whatsapp** without knowing compression `algorithm`
7
+
8
+ <div align="center">
9
+ <img height="60" src="/media/whatsapp_logo.png">
10
+ <h2 align="center">๐Ÿ—œ๏ธCompress Image, Video, and Audio same like Whatsapp</h2>
11
+ </div>
12
+
13
+ #### Why should we use react-native-compress over [FFmpeg](https://www.ffmpeg.org/)?
14
+
15
+ We should use **react-native-compressor** instead of **FFmpeg** because **react-native-compressor** gives you same compression of **Whatsapp** (`Image, Video, and Audio`) without knowing the algorithm of compression + it is lightweight only increase **50 KB Size** Size in APK while **FFmpeg** increase ~> **9 MB Size** in **APK**, and we have to give manual image/video/Audo size and quality as well as
16
+
17
+ **If you find this package useful hit the star** ๐ŸŒŸ
18
+
1
19
  ### Would you like to support me?
2
20
 
3
21
  <div align="center">
4
22
  <a href="https://github.com/numandev1?tab=followers">
5
23
  <img src="https://img.shields.io/github/followers/numandev1?label=Follow%20%40numandev1&style=social" height="36" />
6
24
  </a>
25
+ <a href="https://twitter.com/numandev1/">
26
+ <img src="https://img.shields.io/twitter/follow/numandev1?label=Follow%20%40numandev1&style=social" height="36" />
27
+ </a>
7
28
  <a href="https://www.youtube.com/channel/UCYCUspfN7ZevgCj3W5GlFAw"><img src="https://img.shields.io/youtube/channel/subscribers/UCYCUspfN7ZevgCj3W5GlFAw?style=social" height="36" /><a/>
8
29
  </br>
9
30
  <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,22 +32,7 @@
11
32
 
12
33
  ---
13
34
 
14
- # react-native-compressor
15
-
16
- <!-- Header -->
17
-
18
- <p align="center">
19
- <b>Compress videos, images and audio before upload</b>
20
- <br />
21
- </p>
22
-
23
- <p align="center">
24
- <img height="450" src="/media/cover.png">
25
- </p>
26
-
27
- **react-native-compressor** package is a set of functions that allow you compress `Image`,`Audio` and `Video`
28
-
29
- **If you find this package useful hit the star** ๐ŸŒŸ
35
+ #### See the [Benchmarks](#benchmark)
30
36
 
31
37
  # Table of Contents
32
38
 
@@ -395,7 +401,7 @@ if you want to convert
395
401
  - `content://` to `file:///` for android
396
402
  - `ph://` to `file:///` for IOS
397
403
 
398
- the you can you `getRealPath` function like this
404
+ then you can call `getRealPath` function like this
399
405
 
400
406
  ```js
401
407
  import { getRealPath } from 'react-native-compressor';
@@ -417,6 +423,16 @@ const randomFilePathForSaveFile = await generateFilePath('mp4'); // file://fil
417
423
 
418
424
  - ##### `generateFilePath(fileextension: string)`
419
425
 
426
+ ## Benchmark
427
+
428
+ [<img height="30" src="/media/whatsapp_logo.png"> Whatsapp:](https://apps.apple.com/us/app/whatsapp-messenger/id310633997) compresses Images,Videos and Audios in every effect way
429
+
430
+ <p align="center">
431
+ <img height="450" src="/media/branchmark_for_images.png">
432
+ <br /> <br />
433
+ <img height="450" src="/media/benchmark_for_videos.png">
434
+ </p>
435
+
420
436
  ## Contributing
421
437
 
422
438
  See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
@@ -407,7 +407,7 @@ public class AudioCompressor {
407
407
  return -1;
408
408
  }
409
409
 
410
-
410
+ @SuppressLint("WrongConstant")
411
411
  @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
412
412
  private long writeAudioTrack(MediaExtractor extractor, MediaMuxer mediaMuxer, MediaCodec.BufferInfo info, File file, int muxerTrackIndex ) throws Exception {
413
413
  int trackIndex = selectTrack(extractor, true);
@@ -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:/"+destinationPath);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "This library compress image, video and audio",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",