Gathering detailed insights and metrics for @imsourajit/react-native-compressor
Gathering detailed insights and metrics for @imsourajit/react-native-compressor
Gathering detailed insights and metrics for @imsourajit/react-native-compressor
Gathering detailed insights and metrics for @imsourajit/react-native-compressor
🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨
npm install @imsourajit/react-native-compressor
Typescript
Module System
Node Version
NPM Version
44.9
Supply Chain
58.7
Quality
65.2
Maintenance
50
Vulnerability
93.8
License
Kotlin (40.07%)
Swift (32.36%)
TypeScript (18.12%)
Java (3.53%)
Ruby (1.63%)
Objective-C++ (1.51%)
JavaScript (1.28%)
Shell (0.79%)
Objective-C (0.68%)
C (0.04%)
Total Downloads
686
Last Day
1
Last Week
5
Last Month
10
Last Year
452
MIT License
1,091 Stars
363 Commits
109 Forks
9 Watchers
14 Branches
20 Contributors
Updated on May 13, 2025
Minified
Minified + Gzipped
Latest Version
1.6.2
Package Id
@imsourajit/react-native-compressor@1.6.2
Unpacked Size
340.72 kB
Size
112.10 kB
File Count
87
NPM Version
9.5.0
Node Version
19.7.0
Published on
May 22, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
66.7%
5
Compared to previous week
Last Month
66.7%
10
Compared to previous month
Last Year
93.2%
452
Compared to previous year
2
21
Compress videos, images and audio before upload
react-native-compressor package is a set of functions that allow you compress Image
,Audio
and Video
If you find this package useful hit the star 🌟
1yarn add react-native-compressor@rnlessthan65
1yarn add react-native-compressor
expo install react-native-compressor
Add the Compressor plugin to your Expo config (app.json
, app.config.json
or app.config.js
):
1{ 2 "name": "my app", 3 "plugins": ["react-native-compressor"] 4}
Finally, compile the mods:
expo prebuild
To apply the changes, build a new binary with EAS:
eas build
Automatic linking is supported for both Android
and IOS
Note: If you are using react-native version 0.60 or higher you don't need to link this package.
1react-native link react-native-compressor
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-compressor
and add Compressor.xcodeproj
libCompressor.a
to your project's Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.reactnativecompressor.CompressorPackage;
to the imports at the top of the filenew CompressorPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-compressor'
project(':react-native-compressor').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-compressor/android')
android/app/build.gradle
:
compile project(':react-native-compressor')
1import { Image } from 'react-native-compressor'; 2 3const result = await Image.compress('file://path_of_file/image.jpg', { 4 compressionMethod: 'auto', 5});
Here is this package comparison of images compression with WhatsApp
1import { Image } from 'react-native-compressor'; 2 3const result = await Image.compress('file://path_of_file/image.jpg', { 4 maxWidth: 1000, 5 quality: 0.8, 6});
1import { Video } from 'react-native-compressor'; 2 3const result = await Video.compress( 4 'file://path_of_file/BigBuckBunny.mp4', 5 { 6 compressionMethod: 'auto', 7 }, 8 (progress) => { 9 if (backgroundMode) { 10 console.log('Compression Progress: ', progress); 11 } else { 12 setCompressingProgress(progress); 13 } 14 } 15);
Here is this package comparison of video compression with WhatsApp
1import { Video } from 'react-native-compressor'; 2 3const result = await Video.compress( 4 'file://path_of_file/BigBuckBunny.mp4', 5 {}, 6 (progress) => { 7 if (backgroundMode) { 8 console.log('Compression Progress: ', progress); 9 } else { 10 setCompressingProgress(progress); 11 } 12 } 13);
1import { Video } from 'react-native-compressor'; 2 3let cancellationVideoId = ''; 4 5const result = await Video.compress( 6 'file://path_of_file/BigBuckBunny.mp4', 7 { 8 compressionMethod: 'auto', 9 // getCancellationId for get video id which we can use for cancel compression 10 getCancellationId: (cancellationId) => 11 (cancellationVideoId = cancellationId), 12 }, 13 (progress) => { 14 if (backgroundMode) { 15 console.log('Compression Progress: ', progress); 16 } else { 17 setCompressingProgress(progress); 18 } 19 } 20); 21 22// we can cancel video compression by calling cancelCompression with cancel video id which we can get from getCancellationId function while compression 23Video.cancelCompression(cancellationVideoId);
1import { Audio } from 'react-native-compressor'; 2 3const result = await Audio.compress( 4 'file://path_of_file/file_example_MP3_2MG.mp3', 5 { quality: 'medium' } 6);
1import { backgroundUpload } from 'react-native-compressor'; 2 3const headers = {}; 4 5const uploadResult = await backgroundUpload( 6 url, 7 fileUrl, 8 { httpMethod: 'PUT', headers }, 9 (written, total) => { 10 console.log(written, total); 11 } 12);
compress(value: string, options?: CompressorOptions): Promise<string>
Compresses the input file URI or base-64 string with the specified options. Promise returns a string after compression has completed. Resizing will always keep the original aspect ratio of the image, the maxWidth
and maxHeight
are used as a boundary.
compressionMethod: compressionMethod
(default: "manual")if you want to compress images like whatsapp then make this prop auto
. Can be either manual
or auto
, defines the Compression Method.
maxWidth: number
(default: 1280)The maximum width boundary used as the main boundary in resizing a landscape image.
maxHeight: number
(default: 1280)The maximum height boundary used as the main boundary in resizing a portrait image.
quality: number
(default: 0.8)The quality modifier for the JPEG
file format, can be specified when output is PNG
but will be ignored.
input: InputType
(default: uri)Can be either uri
or base64
, defines the contentents of the value
parameter.
output: OutputType
(default: jpg)Can be either jpg
or png
, defines the output image format.
returnableOutputType: ReturnableOutputType
(default: uri)Can be either uri
or base64
, defines the Returnable output image format.
compress(url: string, options?: videoCompresssionType , onProgress?: (progress: number)): Promise<string>
cancelCompression(cancellationId: string): void
we can get cancellationId from getCancellationId
which is the callback method of compress method options
compressionMethod: compressionMethod
(default: "manual")if you want to compress videos like whatsapp then make this prop auto
. Can be either manual
or auto
, defines the Compression Method.
maxSize: number
(default: 640)The maximum size can be height in case of portrait video or can be width in case of landscape video.
bitrate: string
bitrate of video which reduce or increase video size. if compressionMethod will auto then this prop will not work
minimumFileSizeForCompress: number
(default: 16)16 means 16mb. default our package do not compress under 16mb video file. minimumFileSizeForCompress will allow us to change this 16mb offset. fixed #26
getCancellationId: function
getCancellationId
is a callback function that gives us compress video id, which can be used in Video.cancelCompression
method to cancel the compression
compress(url: string, options?: audioCompresssionType): Promise<string>
quality: qualityType
(default: medium)low
| medium
| high
Note: Audio compression will be add soon
FileSystemUploadOptions
1type FileSystemUploadOptions = ( 2 | { 3 uploadType?: FileSystemUploadType.BINARY_CONTENT, 4 } 5 | { 6 uploadType: FileSystemUploadType.MULTIPART, 7 fieldName?: string, 8 mimeType?: string, 9 parameters?: Record<string, string>, 10 } 11) & { 12 headers?: Record<string, string>, 13 httpMethod?: FileSystemAcceptedUploadHttpMethod, 14 sessionType?: FileSystemSessionType, 15};
if you want to get metadata of video than you can use this function
1import { getVideoMetaData } from 'react-native-compressor'; 2 3const metaData = await getVideoMetaData(filePath);
{
"duration": "6",
"extension": "mp4",
"height": "1080",
"size": "16940.0",
"width": "1920"
}
getVideoMetaData(path: string)
if you want to convert
content://
to file:///
for androidph://
to file:///
for IOSthe you can you getRealPath
function like this
1import { getRealPath } from 'react-native-compressor'; 2 3const realPath = await getRealPath(fileUri, 'video'); // file://file_path.extension
getRealPath(path: string, type: string = 'video'|'image')
if you wanna make random file path in cache folder then you can use this method like this
1import { generateFilePath } from 'react-native-compressor'; 2 3const randomFilePathForSaveFile = await generateFilePath('mp4'); // file://file_path.mp4
generateFilePath(fileextension: string)
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
9 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 9
Reason
binaries present in source code
Details
Reason
Found 6/20 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
54 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-12
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More