react-native-compressor 1.8.22 → 1.8.24

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,
@@ -294,7 +294,7 @@ class ImageCompressor {
294
294
  if let _image = image {
295
295
  image = ImageCompressor.scaleAndRotateImage(_image)
296
296
  let outputExtension = ImageCompressorOptions.getOutputInString(options.output)
297
- let resizedImage = ImageCompressor.manualResize(_image, maxWidth: options.maxWidth, maxHeight: options.maxHeight)
297
+ let resizedImage = ImageCompressor.manualResize(image!, maxWidth: options.maxWidth, maxHeight: options.maxHeight)
298
298
  let isBase64 = options.returnableOutputType == .rbase64
299
299
  return ImageCompressor.manualCompress(resizedImage, output: options.output.rawValue, quality: options.quality, outputExtension: outputExtension, isBase64: isBase64,disablePngTransparency: options.disablePngTransparency,actualImagePath: imagePath)
300
300
  } else {
@@ -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.24",
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",