react-native-compressor 1.8.22 → 1.8.23

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,3 +1,5 @@
1
+ <img src="https://numan.dev/images/child-lives-matter.png" />
2
+
1
3
  <div align="center">
2
4
  <img height="150" src="/media/logo.png" />
3
5
  </div>
@@ -26,8 +26,8 @@ object AutoVideoCompression {
26
26
  val actualWidth = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)!!.toInt()
27
27
  val bitrate = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE)!!.toInt()
28
28
  val scale = if (actualWidth > actualHeight) maxSize / actualWidth else maxSize / actualHeight
29
- val resultWidth = Math.round(actualWidth * scale / 2) * 2
30
- val resultHeight = Math.round(actualHeight * scale / 2) * 2
29
+ val resultWidth = Math.round(actualWidth * Math.min(scale, 1f) / 2) * 2
30
+ val resultHeight = Math.round(actualHeight * Math.min(scale, 1f) / 2) * 2
31
31
  val videoBitRate = makeVideoBitrate(
32
32
  actualHeight, actualWidth,
33
33
  bitrate,
@@ -154,7 +154,7 @@ class VideoCompressor {
154
154
  let minValue:Float=min(Float(originalHeight)/Float(height),Float(originalWidth)/Float(width))
155
155
  var remeasuredBitrate:Int = Int(Float(originalBitrate) / minValue)
156
156
  remeasuredBitrate = Int(Float(remeasuredBitrate)*compressFactor)
157
- let minBitrate:Int = self.getVideoBitrateWithFactor(f: minCompressFactor) / (1280 * 720 / (width * height))
157
+ let minBitrate:Int = Int(Float(self.getVideoBitrateWithFactor(f: minCompressFactor)) / (1280 * 720 / Float(width * height)))
158
158
  if (originalBitrate < minBitrate) {
159
159
  return remeasuredBitrate;
160
160
  }
@@ -186,8 +186,8 @@ class VideoCompressor {
186
186
 
187
187
  let bitrate=Float(abs(track.estimatedDataRate));
188
188
  let scale:Float = actualWidth > actualHeight ? (Float(maxSize) / actualWidth) : (Float(maxSize) / actualHeight);
189
- let resultWidth:Float = round(actualWidth * scale / 2) * 2;
190
- let resultHeight:Float = round(actualHeight * scale / 2) * 2;
189
+ let resultWidth:Float = round(actualWidth * min(scale, 1) / 2) * 2;
190
+ let resultHeight:Float = round(actualHeight * min(scale, 1) / 2) * 2;
191
191
 
192
192
  let videoBitRate:Int = self.makeVideoBitrate(
193
193
  originalHeight: Int(actualHeight), originalWidth: Int(actualWidth),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.8.22",
3
+ "version": "1.8.23",
4
4
  "description": "Compress Image, Video, and Audio same like Whatsapp & Auto/Manual Compression | Background Upload | Download File | Create Video Thumbnail",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",