{"id":23638024,"url":"https://github.com/emekalites/react-native-compress-image","last_synced_at":"2025-08-31T13:31:35.879Z","repository":{"id":41869408,"uuid":"105317650","full_name":"emekalites/react-native-compress-image","owner":"emekalites","description":"compress image with react native","archived":false,"fork":false,"pushed_at":"2022-04-25T17:12:48.000Z","size":599,"stargazers_count":23,"open_issues_count":17,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-20T20:41:53.499Z","etag":null,"topics":["android","compress","image","ios","react","react-native"],"latest_commit_sha":null,"homepage":"","language":"Java","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/emekalites.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-29T21:13:13.000Z","updated_at":"2023-11-18T23:21:10.000Z","dependencies_parsed_at":"2022-08-11T19:50:12.890Z","dependency_job_id":null,"html_url":"https://github.com/emekalites/react-native-compress-image","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emekalites%2Freact-native-compress-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emekalites%2Freact-native-compress-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emekalites%2Freact-native-compress-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emekalites%2Freact-native-compress-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emekalites","download_url":"https://codeload.github.com/emekalites/react-native-compress-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231596179,"owners_count":18397852,"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":["android","compress","image","ios","react","react-native"],"created_at":"2024-12-28T07:21:38.398Z","updated_at":"2024-12-28T07:21:38.892Z","avatar_url":"https://github.com/emekalites.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native Compress Image\n[![npm version](https://badge.fury.io/js/react-native-compress-image.svg)](https://badge.fury.io/js/react-native-compress-image)\n[![npm downloads](https://img.shields.io/npm/dt/react-native-compress-image.svg)](https://badge.fury.io/js/react-native-compress-image)\n\nReact Native Compress Image for Android\n\n**NOTE: The iOS side of this module will be included when i have figured it out.**\n\n## Installation\n\n`npm install --save react-native-compress-image`\n\n`react-native link react-native-compress-image`\n\n**NOTE: For Android, you will still have to manually update the AndroidManifest.xml (as below) in order to use Scheduled Notifications.**\n\n## Android manual Installation\n\nIn your `AndroidManifest.xml`\n```xml\n\u003cuses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/\u003e\n\u003cuses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/\u003e\n```\n\nIn `android/settings.gradle`\n```gradle\ninclude ':react-native-compress-image'\nproject(':react-native-compress-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-compress-image/android')\n```\n\nin `android/app/build.gradle`\n```java\ndependencies {\n    compile project(':react-native-compress-image')  // \u003c--- Add package to dependencies\n    compile fileTree(dir: \"libs\", include: [\"*.jar\"])\n    compile \"com.android.support:appcompat-v7:23.0.1\"\n    compile \"com.facebook.react:react-native:+\"\n    ....\n}\n```\n\nin `MainApplication.java`:\n\n```java\nimport com.emekalites.react.compress.image.ImageCompressPackage;  // \u003c--- Import Package\n\npublic class MainApplication extends Application implements ReactApplication {\n\n  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {\n      @Override\n      protected boolean getUseDeveloperSupport() {\n        return BuildConfig.DEBUG;\n      }\n\n      @Override\n      protected List\u003cReactPackage\u003e getPackages() {\n      \treturn Arrays.\u003cReactPackage\u003easList(\n          new MainReactPackage(),\n          new ImageCompressPackage() \t\t// \u003c---- Add the Package\n        );\n      }\n  };\n}\n```\n\n## Usage\n\n```javascript\nimport CompressImage from 'react-native-compress-image';\n\nCompressImage.createCompressedImage(imageUri, appDirectory).then((response) =\u003e {\n  // response.uri is the URI of the new image that can now be displayed, uploaded...\n  // response.path is the path of the new image\n  // response.name is the name of the new image with the extension\n  // response.size is the size of the new image\n}).catch((err) =\u003e {\n  // Oops, something went wrong. Check that the filename is correct and\n  // inspect err to get more details.\n});\n\nCompressImage.createCustomCompressedImage(imageUri, appDirectory, maxWidth, maxHeight, quality).then((response) =\u003e {\n  // response.uri is the URI of the new image that can now be displayed, uploaded...\n  // response.path is the path of the new image\n  // response.name is the name of the new image with the extension\n  // response.size is the size of the new image\n}).catch((err) =\u003e {\n  // Oops, something went wrong. Check that the filename is correct and\n  // inspect err to get more details.\n});\n```\n## Sample App\n\nA basic, sample app is available in [the `example` folder](https://github.com/emekalites/react-native-compress-image/tree/master/example). It uses the module to compress a photo from the Camera Roll.\n\n## API\n\n### `promise createCompressedImage(imageUri, appDirectory)`\n\nThe promise resolves with an object containing: `path`, `uri`, `name` and `size` of the new file. The URI can be used directly as the `source` of an [`\u003cImage\u003e`](https://facebook.github.io/react-native/docs/image.html) component.\n\nOption | Description\n------ | -----------\nimageUri | Path of image file whether jpeg or png\nappDirectory | The folder or path to save the compressed image\n\n### `promise createCustomCompressedImage(imageUri, appDirectory, maxWidth, maxHeight, quality)`\n\nThe promise resolves with an object containing: `path`, `uri`, `name` and `size` of the new file. The URI can be used directly as the `source` of an [`\u003cImage\u003e`](https://facebook.github.io/react-native/docs/image.html) component.\n\nOption | Description\n------ | -----------\nimageUri | Path of image file whether jpeg or png\nappDirectory | The folder or path to save the compressed image\nmaxWidth | Image maximum width\nmaxHeight | Image maximum height\nquality | Image quality\n\n## Credits\n\n[https://github.com/zetbaitsu/Compressor](https://github.com/zetbaitsu/Compressor)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femekalites%2Freact-native-compress-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femekalites%2Freact-native-compress-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femekalites%2Freact-native-compress-image/lists"}