{"id":20144717,"url":"https://github.com/widuu/react-native-save-image","last_synced_at":"2025-04-09T19:16:56.520Z","repository":{"id":57339700,"uuid":"100179485","full_name":"widuu/react-native-save-image","owner":"widuu","description":"react-native Android 保存网络图片到相册","archived":false,"fork":false,"pushed_at":"2017-08-13T13:59:19.000Z","size":10,"stargazers_count":4,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T21:11:19.572Z","etag":null,"topics":["android","react-native"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/widuu.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-08-13T13:45:06.000Z","updated_at":"2022-03-14T09:05:29.000Z","dependencies_parsed_at":"2022-09-26T16:31:33.173Z","dependency_job_id":null,"html_url":"https://github.com/widuu/react-native-save-image","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Freact-native-save-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Freact-native-save-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Freact-native-save-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Freact-native-save-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/widuu","download_url":"https://codeload.github.com/widuu/react-native-save-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247704569,"owners_count":20982298,"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","react-native"],"created_at":"2024-11-13T22:11:49.709Z","updated_at":"2025-04-09T19:16:56.499Z","avatar_url":"https://github.com/widuu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# react-native-save-image\n\n\u003e react-native `Android`版 保存网络图片到相册\n\n## 安装\n\n\u003e 快速安装\n\n`$ npm install react-native-save-image --save`\n\n`$ react-native link react-native-save-image` or `rnpm link react-native-save-image`\n\n\u003e 手动配置\n\n1. 修改 `android/settings.gradle`，添加如下的代码：\n\n```\n    \tinclude ':react-native-save-image'   \n\tproject(':react-native-save-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-save-image/android')\n```\n\n2. 修改 `android/app/build.gradle file`\n\n```\n\t...\n\tdependencies {\n\t    ...\n\t    compile project(':react-native-splash-screen')\n\t}\n```\n\n3. 修改 `MainApplication.java `\n\n```\n    import com.widuu.SaveImagePackage; // 顶部导入\n\n    @Override\n    protected List\u003cReactPackage\u003e getPackages() {\n      return Arrays.\u003cReactPackage\u003easList(\n          new MainReactPackage(),\n          new SaveImagePackage(), // 这里添加\n      );\n    }\n```\n\n## 使用\n\n```\n\timport SaveImage from 'react-native-save-image';\n\n\texport default class SaveImage extends React.Component {\n\n\t    componentDidMount() {\n\t    \tSaveImage.setAlbumName('相册文件夹名称');\n    \t\tSaveImage.setCompressQuality(80); // 整数品质\n\t    }\n\n\t    render(){\n\t    \treturn(\n\t\t    \u003cView style={styles.container}\u003e\n\t\t        \u003cTouchableHighlight onLongPress={()=\u003eSaveImage.downloadImage(图片地址)}\u003e\n\t\t \t    \u003cImage\n\t\t\t        source={{uri:图片地址}}\n\t\t\t        style={styles.images}\n\t\t\t        resizeMode='contain'\n\t\t\t     /\u003e\n              \t\t\u003c/TouchableHighlight\u003e\n            \t    \u003c/View\u003e\n\t    \t);\n\t    }\n\t}\n```\n\n## API\n\n    SaveImage.setAlbumName(String dirName); \t\t   // 保存到相册的文件夹\n    SaveImage.setCompressQuality(int compressQuality);     // 整数品质\n    SaveImage.downloadImage(String Url);  \t           // 图片地址,例如 http://www.baidu.com/logo.png\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiduu%2Freact-native-save-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiduu%2Freact-native-save-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiduu%2Freact-native-save-image/lists"}