{"id":15093363,"url":"https://github.com/numandev1/react-native-compressor","last_synced_at":"2026-04-03T21:11:21.735Z","repository":{"id":41154405,"uuid":"371665826","full_name":"numandev1/react-native-compressor","owner":"numandev1","description":"🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨","archived":false,"fork":false,"pushed_at":"2024-09-11T10:43:12.000Z","size":2529,"stargazers_count":934,"open_issues_count":52,"forks_count":87,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-29T14:54:41.766Z","etag":null,"topics":["audio","background-upload","bitrate","compress","compress-audio","compress-images","compress-videos","compression","compressor","download","downloader","image","javascript","react-native","thumbnail","thumbnail-generator","upload","uploader","video","whatsapp"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/numandev1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"numandev1","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"http://buymeacoffee.com/numan.dev"}},"created_at":"2021-05-28T10:34:48.000Z","updated_at":"2024-10-28T10:19:17.000Z","dependencies_parsed_at":"2023-07-26T23:26:50.928Z","dependency_job_id":"ed979918-d783-4bc9-b2e5-b3eef3f3da45","html_url":"https://github.com/numandev1/react-native-compressor","commit_stats":{"total_commits":240,"total_committers":17,"mean_commits":"14.117647058823529","dds":"0.12916666666666665","last_synced_commit":"40deab8de03a9a08a4abf22244d7a678ff12485c"},"previous_names":["shobbak/react-native-compressor"],"tags_count":89,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numandev1%2Freact-native-compressor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numandev1%2Freact-native-compressor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numandev1%2Freact-native-compressor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numandev1%2Freact-native-compressor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numandev1","download_url":"https://codeload.github.com/numandev1/react-native-compressor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161262,"owners_count":21057552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","background-upload","bitrate","compress","compress-audio","compress-images","compress-videos","compression","compressor","download","downloader","image","javascript","react-native","thumbnail","thumbnail-generator","upload","uploader","video","whatsapp"],"created_at":"2024-09-25T11:21:50.930Z","updated_at":"2026-01-07T01:01:26.135Z","avatar_url":"https://github.com/numandev1.png","language":"Kotlin","funding_links":["https://github.com/sponsors/numandev1","http://buymeacoffee.com/numan.dev","https://www.buymeacoffee.com/numan.dev"],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://numan.dev/images/child-lives-matter.png\" /\u003e\n\n\u003cdiv align=\"center\"\u003e\n \u003cimg height=\"150\" src=\"/media/logo.png\" /\u003e\n\u003c/div\u003e\n \n\u003cbr/\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![GitHub Repo stars](https://img.shields.io/badge/React_Native-20232A?style=for-the-badge\u0026logo=react\u0026logoColor=61DAFB)](#Installation)\n[![GitHub Repo stars](https://img.shields.io/badge/Expo-1B1F23?style=for-the-badge\u0026logo=expo\u0026logoColor=white)](#managed-expo)\n[![GitHub Repo stars](https://img.shields.io/static/v1?style=for-the-badge\u0026message=Discord\u0026color=5865F2\u0026logo=Discord\u0026logoColor=FFFFFF\u0026label=)](https://discord.gg/6Wx8Em8KAN)\n[![GitHub Repo stars](https://img.shields.io/github/stars/numandev1/react-native-compressor?style=for-the-badge\u0026logo=github)](https://github.com/numandev1/react-native-compressor/stargazers)\n![npm](https://img.shields.io/npm/dt/react-native-compressor?style=for-the-badge)\n\n\u003c/div\u003e\n\n**REACT-NATIVE-COMPRESSOR** is a react-native package, which helps us to Compress `Image`, `Video`, and `Audio` before uploading, same like **Whatsapp** without knowing the compression `algorithm`\n\n\u003cdiv align=\"center\"\u003e\n \u003ch4\u003eAuto/Manual Compression | Background Upload | Download File | Create Video Thumbnail\u003c/h4\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cpre\u003e\n\u003cimg height=\"90\" src=\"/media/whatsapp_logo.png\"/\u003e               \u003cimg height=\"90\" src=\"/media/compress_media.png\"/\u003e\n\u003c/pre\u003e\n\u003ch2 align=\"center\"\u003e🗜️Compress Image, Video, and Audio same like Whatsapp\u003c/h2\u003e\n\u003c/div\u003e\n\n#### Why should we use react-native-compress over [FFmpeg](https://www.ffmpeg.org/)?\n\nWe 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 ~\u003e **9 MB Size** in **APK**, and we have to give manual image/video/Audo size and quality as well as\n\n**If you find this package useful hit the star** 🌟\n\n### Would you like to support me?\n\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://github.com/numandev1?tab=followers\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/followers/numandev1?label=Follow%20%40numandev1\u0026style=social\" height=\"36\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/numandev1/\"\u003e\n    \u003cimg src=\"https://img.shields.io/twitter/follow/numandev1?label=Follow%20%40numandev1\u0026style=social\" height=\"36\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.youtube.com/channel/UCYCUspfN7ZevgCj3W5GlFAw\"\u003e\u003cimg src=\"https://img.shields.io/youtube/channel/subscribers/UCYCUspfN7ZevgCj3W5GlFAw?style=social\" height=\"36\" /\u003e\u003ca/\u003e\n\u003c/br\u003e\n\u003ca href=\"https://www.buymeacoffee.com/numan.dev\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" \u003e\u003c/a\u003e\n\u003c/div\u003e\n\n---\n\n#### See the [Benchmarks](#benchmark)\n\n# Table of Contents\n\n\u003cdetails\u003e\n\u003csummary\u003eOpen Table of Contents\u003c/summary\u003e\n\n- [Installation](#installation)\n  - [For React Native](#Installation)\n  - [Managed Expo](#managed-expo)\n- [Usage](#usage)\n  - [Image](#image)\n    - [Automatic Image Compression Like Whatsapp](#automatic-image-compression-like-whatsapp)\n    - [Manual Image Compression](#manual-image-compression)\n    - [ImageCompressor API Docs](#imagecompressor)\n  - [Video](#video)\n    - [Automatic Video Compression Like Whatsapp](#automatic-video-compression-like-whatsapp)\n    - [Manual Video Compression](#manual-video-compression)\n    - [Cancel Video Compression](#cancel-video-compression)\n    - [Video Api Docs](#video-1)\n  - [Audio](#audio)\n  - [Background Upload](#background-upload)\n  - [Cancel Background Upload](#cancel-background-upload)\n  - [Download File](#download)\n  - [Create Video Thumbnail and Clear Cache](#create-video-thumbnail-and-clear-cache)\n\n* [Other Utilities](#api)\n  - [Background Upload](#background-upload-1)\n  - [Cancel Background Upload](#cancel-background-upload-1)\n  - [Get Metadata Of Image](#get-metadata-of-image)\n  - [Get Metadata Of Video](#get-metadata-of-video)\n  - [Get Real Path](#get-real-path)\n  - [Get Temp file Path](#get-temp-file-path)\n  \u003c/details\u003e\n\n## Installation\n\n```sh\nyarn add react-native-compressor\n```\n\n### [New Architecture (Turbo Module)](https://reactnative.dev/docs/new-architecture-intro) Supported\n\nyou can give feedback on [Discord channel](https://discord.gg/6Wx8Em8KAN)\n\n### Managed Expo\n\n```\nexpo install react-native-compressor\n```\n\nAdd the Compressor plugin to your Expo config (`app.json`, `app.config.json` or `app.config.js`):\n\n```json\n{\n  \"name\": \"my app\",\n  \"plugins\": [\"react-native-compressor\"]\n}\n```\n\nFinally, compile the mods:\n\n```\nexpo prebuild\n```\n\nTo apply the changes, build a new binary with EAS:\n\n```\neas build\n```\n\n### Automatic linking (for React Native \u003e= 0.60 only)\n\nAutomatic linking is supported for both `Android` and `IOS`\n\n### Linking (for React Native \u003c= 0.59 only)\n\nNote: If you are using react-native version 0.60 or higher you don't need to link this package.\n\n```sh\nreact-native link react-native-compressor\n```\n\n### Manual installation\n\n#### iOS\n\n1. In XCode, open Podfile\n2. paste this line `pod 'react-native-compressor', :path =\u003e '../node_modules/react-native-compressor'` into `Podfile`\n3. run this command inside ios folder `pod install`\n4. Run your project (`Cmd+R`)\u003c\n\n#### Android\n\n1. Open up `android/app/src/main/java/[...]/MainActivity.java`\n\n- Add `import com.reactnativecompressor.CompressorPackage;` to the imports at the top of the file\n- Add `new CompressorPackage()` to the list returned by the `getPackages()` method\n\n2. Append the following lines to `android/settings.gradle`:\n   ```\n   include ':react-native-compressor'\n   project(':react-native-compressor').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-compressor/android')\n   ```\n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n   ```\n     compile project(':react-native-compressor')\n   ```\n\n## Usage\n\n### Image\n\n##### Automatic Image Compression Like Whatsapp\n\n```js\nimport { Image } from 'react-native-compressor';\n\nconst result = await Image.compress('file://path_of_file/image.jpg');\n// OR\nconst result = await Image.compress('https://path_of_file/image.jpg', {\n  progressDivider: 10,\n  downloadProgress: (progress) =\u003e {\n    console.log('downloadProgress: ', progress);\n  },\n});\n```\n\n[Here is this package comparison of images compression with WhatsApp](https://docs.google.com/spreadsheets/d/13TsnC1c7NOC9aCjzN6wkKurJQPeGRNwDhWsQOkXQskU/edit?usp=sharing)\n\n##### Manual Image Compression\n\n```js\nimport { Image } from 'react-native-compressor';\n\nconst result = await Image.compress('file://path_of_file/image.jpg', {\n  compressionMethod: 'manual',\n  maxWidth: 1000,\n  quality: 0.8,\n});\n```\n\n### Video\n\n##### Automatic Video Compression Like Whatsapp\n\n```js\nimport { Video } from 'react-native-compressor';\n\nconst result = await Video.compress(\n  'file://path_of_file/BigBuckBunny.mp4',\n  {},\n  (progress) =\u003e {\n    console.log('Compression Progress: ', progress);\n  }\n);\n\n//OR\n\nconst result = await Video.compress(\n  'https://example.com/video.mp4',\n  {\n    progressDivider: 10,\n    downloadProgress: (progress) =\u003e {\n      console.log('downloadProgress: ', progress);\n    },\n  },\n  (progress) =\u003e {\n    console.log('Compression Progress: ', progress);\n  }\n);\n```\n\n[Here is this package comparison of video compression with WhatsApp](https://docs.google.com/spreadsheets/d/13TsnC1c7NOC9aCjzN6wkKurJQPeGRNwDhWsQOkXQskU/edit#gid=1055406534)\n\n##### Manual Video Compression\n\n```js\nimport { Video } from 'react-native-compressor';\n\nconst result = await Video.compress(\n  'file://path_of_file/BigBuckBunny.mp4',\n  {\n    compressionMethod: 'manual',\n  },\n  (progress) =\u003e {\n    console.log('Compression Progress: ', progress);\n  }\n);\n```\n\n##### Cancel Video Compression\n\n```js\nimport { Video } from 'react-native-compressor';\n\nlet cancellationVideoId = '';\n\nconst result = await Video.compress(\n  'file://path_of_file/BigBuckBunny.mp4',\n  {\n    compressionMethod: 'auto',\n    // getCancellationId for get video id which we can use for cancel compression\n    getCancellationId: (cancellationId) =\u003e\n      (cancellationVideoId = cancellationId),\n  },\n  (progress) =\u003e {\n    if (backgroundMode) {\n      console.log('Compression Progress: ', progress);\n    } else {\n      setCompressingProgress(progress);\n    }\n  }\n);\n\n// we can cancel video compression by calling cancelCompression with cancel video id which we can get from getCancellationId function while compression\nVideo.cancelCompression(cancellationVideoId);\n```\n\n### Audio\n\n```js\nimport { Audio } from 'react-native-compressor';\n\nconst result = await Audio.compress(\n  'file://path_of_file/file_example_MP3_2MG.wav', // recommended wav file but can be use mp3 file\n  { quality: 'medium' }\n);\n\n// OR\n\nconst result = await Audio.compress(\n  'file://path_of_file/file_example_MP3_2MG.wav', // recommended wav file but can be use mp3 file\n  {\n    bitrate: 64000,\n    samplerate: 44100,\n    channels: 1,\n  }\n);\n```\n\n### Background Upload\n\n```js\nimport { backgroundUpload } from 'react-native-compressor';\n\nconst headers = {};\n\nconst uploadResult = await backgroundUpload(\n  url,\n  fileUrl,\n  { httpMethod: 'PUT', headers },\n  (written, total) =\u003e {\n    console.log(written, total);\n  }\n);\n\n//OR\n\nconst uploadResult = await backgroundUpload(\n  url,\n  fileUrl,\n  { uploadType: UploadType.MULTIPART, httpMethod: 'POST', headers },\n  (written, total) =\u003e {\n    console.log(written, total);\n  }\n);\n```\n\n### Cancel Background Upload\nfor cancellation Upload, there is two ways\n1. by calling, cancelUpload function\n2. by calling abort function\n\n##### cancelUpload (support single and all)\n```js\nimport { cancelUpload, backgroundUpload } from 'react-native-compressor';\n\n// if we will call without passing any param then it will remove last pushed uploading\ncancelUpload()\n\n// if you pass true as second param then it will cancel all the uploading\ncancelUpload(\"\",true)\n\n// if there is multiple files are uploading, and you wanna cancel specific uploading then you pass specific video id like this\nlet videoId=''\nconst uploadResult = await backgroundUpload(\n  url,\n  fileUrl,\n  { httpMethod: 'PUT',  getCancellationId: (cancellationId) =\u003e(videoId = cancellationId), },\n  (written, total) =\u003e {\n    console.log(written, total);\n  }\n);\ncancelUpload(videoId)\n```\n\n##### cancel by calling abort\n```js\nimport { backgroundUpload } from 'react-native-compressor';\n\nconst abortSignalRef = useRef(new AbortController());\n\nconst uploadResult = await backgroundUpload(\n  url,\n  fileUrl,\n  { httpMethod: 'PUT' },\n  (written, total) =\u003e {\n    console.log(written, total);\n  },\n  abortSignalRef.current.signal\n);\n\nabortSignalRef.current?.abort(); // this will cancel uploading\n```\n\n### Download File\n\n```js\nimport { download } from 'react-native-compressor';\n\nconst downloadFileUrl = await download(url, (progress) =\u003e {\n  console.log('downloadProgress: ', progress);\n});\n```\n\n### Video Thumbnail\n\n```js\nimport { createVideoThumbnail, clearCache } from 'react-native-compressor';\n\nconst thumbnail = await createVideoThumbnail(videoUri);\n\nawait clearCache(); // this will clear cache of thumbnails cache directory\n```\n\n# API\n\n## Image\n\n### ImageCompressor\n\n- ###### `compress(value: string, options?: CompressorOptions): Promise\u003cstring\u003e`\n\n  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.\n\n### CompressorOptions\n\n- ###### `compressionMethod: compressionMethod` (default: \"auto\")\n\n  if you want to compress images like **whatsapp** then make this prop `auto`. Can be either `manual` or `auto`, defines the Compression Method.\n\n- ##### `downloadProgress?: (progress: number) =\u003e void;`\n\n  it is callback, only trigger when we pass image url from server\n\n- ##### `progressDivider?: number` (default: 0)\n\n  we uses it when we use downloadProgress\n\n- ###### `maxWidth: number` (default: 1280)\n\n  The maximum width boundary used as the main boundary in resizing a landscape image.\n\n- ###### `maxHeight: number` (default: 1280)\n\n  The maximum height boundary used as the main boundary in resizing a portrait image.\n\n- ###### `quality: number` (default: 0.8)\n\n  The quality modifier for the `JPEG` and `PNG` file format, if your input file is `JPEG` and output file is `PNG` then compressed size can be increase\n\n- ###### `input: InputType` (default: uri)\n\n  Can be either `uri` or `base64`, defines the contentents of the `value` parameter.\n\n- ###### `output: OutputType` (default: jpg)\n\n  The quality modifier for the `JPEG` file format, can be specified when output is `PNG` but will be ignored. if you wanna apply quality modifier then you can enable `disablePngTransparency:true`,\n  **Note:** if you png image have no transparent background then enable `disablePngTransparency:true` modifier is recommended\n\n- ###### `disablePngTransparency: boolean` (default: false)\n\n  when user add `output:'png'` then by default compressed image will have transparent background, and quality will be ignored, if you wanna apply quality then you have to disablePngTransparency like `disablePngTransparency:true`, it will convert transparent background to white\n\n- ###### `returnableOutputType: ReturnableOutputType` (default: uri)\n  Can be either `uri` or `base64`, defines the Returnable output image format.\n\n**if you wanna get image metadata (exif) then [read this](#get-metadata-of-image)**\n\n## Video\n\n- ###### `compress(url: string, options?: videoCompresssionType , onProgress?: (progress: number)): Promise\u003cstring\u003e`\n\n- ###### `cancelCompression(cancellationId: string): void`\n\n  we can get cancellationId from `getCancellationId` which is the callback method of compress method options\n\n- ###### `activateBackgroundTask(onExpired?: (data: any) =\u003e void): Promise\u003cany\u003e`\n  if you wanna compress video while app is in backgroup then you should call this method before compression\n- ###### `deactivateBackgroundTask(): Promise\u003cany\u003e`\n  if you call `activateBackgroundTask` method, then after video compression, you should call `deactivateBackgroundTask` for disable background task mode.\n\n- ###### `getCancellationId: function`\n  `getCancellationId` is a callback function that gives us compress video id, which can be used in `Video.cancelCompression` method to cancel the compression\n\n### videoCompresssionType\n\n- ###### `compressionMethod: compressionMethod` (default: \"manual\")\n\n  if you want to compress videos like **whatsapp** then make this prop `auto`. Can be either `manual` or `auto`, defines the Compression Method.\n\n- ##### `downloadProgress?: (progress: number) =\u003e void;`\n\n  it is callback, only trigger when we pass image url from server\n\n- ##### `progressDivider?: number` (default: 0)\n\n  we uses it when we use downloadProgress/onProgress\n\n- ###### `maxSize: number` (default: 640)\n\n  The maximum size can be height in case of portrait video or can be width in case of landscape video.\n\n- ###### `bitrate: number`\n\n  bitrate of video which reduce or increase video size. if compressionMethod will auto then this prop will not work\n\n- ###### `minimumFileSizeForCompress: number` (default: 0)\n\n  previously default was 16 but now it is 0 by default. 0 mean 0mb. This is an offset, which you can set for minimumFileSizeForCompress will allow this package to dont compress less than or equal to `minimumFileSizeForCompress` ref [#26](https://github.com/numandev1/react-native-compressor/issues/26)\n\n**if you wanna get video metadata then [read this](#get-metadata-of-video)**\n\n## Audio\n\n- ###### `compress(url: string, options?: audioCompresssionType): Promise\u003cstring\u003e`\n  Android: recommended to use `wav` file as we convert mp3 to wav then apply bitrate\n\n### audioCompresssionType\n\n- ###### `quality?: qualityType` (default: medium)\n\n  we can also control bitrate through quality. qualityType can be `low` | `medium` | `high`\n\n- ###### `bitrate?: number` Range [64000-320000]\n\n  we can control bitrate of audio through bitrate, it should be in the range of `64000-320000`\n\n- ###### `samplerate?: number` Range [44100 - 192000]\n\n  we can control samplerate of audio through samplerate, it should be in the range of `44100 - 192000`\n\n- ###### `channels?: number` Typically 1 or 2\n  we can control channels of audio through channels, Typically 1 or 2\n\n## Background Upload\n\n- ###### backgroundUpload: (url: string, fileUrl: string, options: UploaderOptions, onProgress?: ((writtem: number, total: number) =\u003e void) | undefined) =\u003e Promise\u003c any \u003e\n\n- ###### ` UploaderOptions`\n\n```js\nexport enum UploadType {\n  BINARY_CONTENT = 0,\n  MULTIPART = 1,\n}\n\nexport enum UploaderHttpMethod {\n  POST = 'POST',\n  PUT = 'PUT',\n  PATCH = 'PATCH',\n}\n\nexport declare type HTTPResponse = {\n  status: number;\n  headers: Record\u003cstring, string\u003e;\n  body: string;\n};\n\nexport declare type HttpMethod = 'POST' | 'PUT' | 'PATCH';\n\nexport declare type UploaderOptions = (\n  | {\n      uploadType?: UploadType.BINARY_CONTENT;\n      mimeType?: string;\n    }\n  | {\n      uploadType: UploadType.MULTIPART;\n      fieldName?: string;\n      mimeType?: string;\n      parameters?: Record\u003cstring, string\u003e;\n    }\n) \u0026 {\n  headers?: Record\u003cstring, string\u003e;\n  httpMethod?: UploaderHttpMethod;\n  getCancellationId?: (cancellationId: string) =\u003e void;\n};\n```\n\n**Note:** some of the uploader code is borrowed from [Expo](https://github.com/expo/expo)\nI tested file uploader on this backend [Nodejs-File-Uploader](https://github.com/numandev1/nodejs-file-uploader)\n\n### Cancel Background Upload\nfor cancellation Upload, there is two ways, you can use one of it\n- ##### cancelUpload: ( uuid?: string, shouldCancelAll?: boolean) =\u003e void\n  1. If we call without passing any param then it will remove the last pushed uploading\n  2. If you pass true as the second param then it will cancel all the uploading\n  3. if there is multiple files are uploading, and you wanna cancel specific uploading then you pass a specific video ID like this\n\n- ##### we can use [AbortController](https://github.com/facebook/react-native/blob/255fef5263afdf9933ba2f8a3dbcbca39ea9928a/packages/react-native/types/modules/globals.d.ts#L531) in backgroundUpload [Usage](#cancel-background-upload)\n  `const abortSignalRef = useRef(new AbortController());`\n\n  `abortSignalRef.current?.abort();`\n\n### Download\n\n- ##### download: ( fileUrl: string, downloadProgress?: (progress: number) =\u003e void, progressDivider?: number ) =\u003e Promise\u003c string \u003e\n\n### Create Video Thumbnail and Clear Cache\n\n- #### createVideoThumbnail( fileUrl: string, options: {header:Object} ): Promise\u003c{ path: string;size: number; mime: string; width: number; height: number; }\u003e\n\n  it will save the thumbnail of the video into the cache directory and return the thumbnail URI which you can display\n\n- #### clearCache(cacheDir?: string): Promise\u003c string \u003e\n\n  it will clear the cache that was created from createVideoThumbnail, in future this clear cache will be totally customized\n\n### Get Metadata Of Video\n\nif you want to get metadata of video than you can use this function\n\n```js\nimport { getVideoMetaData } from 'react-native-compressor';\n\nconst metaData = await getVideoMetaData(filePath);\n```\n\n```\n{\n\t\"duration\": 20.11,\n\t\"extension\": \"mp4\",\n\t\"height\": 1080,\n\t\"size\": 16940.0,\n\t\"width\": 1920\n}\n```\n\n- ###### `getVideoMetaData(path: string)`\n\n### Get Metadata Of Image\n\nif you want to get metadata of video than you can use this function\n\n```js\nimport { getImageMetaData } from 'react-native-compressor';\n\nconst metaData = await getImageMetaData(filePath);\n```\n\n```\n{\n  \"ImageWidth\": 4032,\n  \"ImageHeight\": 3024,\n  \"Orientation\": 3,\n  \"size\": 4127057,\n  \"extension\": \"jpg\",\n  \"exif\":{...}\n}\n```\n\n- ###### `getImageMetaData(path: string)`\n\n### Get Real Path\n\nif you want to convert\n\n- `content://` to `file:///` for android\n- `ph://` to `file:///` for IOS\n\nthen you can call `getRealPath` function like this\n\n```js\nimport { getRealPath } from 'react-native-compressor';\n\nconst realPath = await getRealPath(fileUri, 'video'); //   file://file_path.extension\n```\n\n- ###### `getRealPath(path: string, type: string = 'video'|'image')`\n\n### Get Temp file Path\n\nif you wanna make random file path in cache folder then you can use this method like this\n\n```js\nimport { generateFilePath } from 'react-native-compressor';\n\nconst randomFilePathForSaveFile = await generateFilePath('mp4'); //   file://file_path.mp4\n```\n\n- ##### `generateFilePath(fileextension: string)`\n\n## Benchmark\n\n[\u003cimg height=\"30\" src=\"/media/whatsapp_logo.png\"\u003e Whatsapp:](https://apps.apple.com/us/app/whatsapp-messenger/id310633997) compresses Images,Videos and Audios in every effect way\n\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"450\" src=\"/media/branchmark_for_images.png\"\u003e\n   \u003cbr /\u003e \u003cbr /\u003e\n  \u003cimg height=\"450\" src=\"/media/benchmark_for_videos.png\"\u003e\n\u003c/p\u003e\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumandev1%2Freact-native-compressor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumandev1%2Freact-native-compressor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumandev1%2Freact-native-compressor/lists"}