{"id":20258836,"url":"https://github.com/pontusab/react-native-image-manipulator","last_synced_at":"2025-04-11T01:13:18.389Z","repository":{"id":36473024,"uuid":"150323506","full_name":"pontusab/react-native-image-manipulator","owner":"pontusab","description":"🗻Manipulate the image provided via uri. Available modifications are rotating, flipping (mirroring), resizing and cropping. ","archived":false,"fork":false,"pushed_at":"2023-01-04T07:23:44.000Z","size":1139,"stargazers_count":23,"open_issues_count":34,"forks_count":39,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T01:13:11.403Z","etag":null,"topics":["java","objective-c","react-native"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pontusab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-25T20:12:57.000Z","updated_at":"2025-03-22T14:08:56.000Z","dependencies_parsed_at":"2023-01-17T02:00:26.406Z","dependency_job_id":null,"html_url":"https://github.com/pontusab/react-native-image-manipulator","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/pontusab%2Freact-native-image-manipulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontusab%2Freact-native-image-manipulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontusab%2Freact-native-image-manipulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pontusab%2Freact-native-image-manipulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pontusab","download_url":"https://codeload.github.com/pontusab/react-native-image-manipulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322571,"owners_count":21084337,"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":["java","objective-c","react-native"],"created_at":"2024-11-14T11:11:50.876Z","updated_at":"2025-04-11T01:13:18.370Z","avatar_url":"https://github.com/pontusab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"An API to modify images stored on the local file system.\n\n## Installation\n\n1. `yarn add https://github.com/pontusab/react-native-image-manipulator`\n2. `pod 'react-native-image-manipulator', :path =\u003e './node_modules/react-native-image-manipulator/ios'`\n3. `pod install`\n\n## API\n\n```js\nimport * as ImageManipulator from 'react-native-image-manipulator';\n```\n\n### `ImageManipulator.manipulateAsync(uri, actions, saveOptions)`\n\nManipulate the image provided via `uri`. Available modifications are rotating, flipping (mirroring), resizing and cropping. Each invocation results in a new file. With one invocation you can provide a set of actions to perform over the image. Overwriting the source file would not have an effect in displaying the result as images are cached.\n\n#### Arguments\n\n- **uri (_string_)** -- URI of the file to manipulate. Should be on the local file system.\n- **actions (_array_)** --\n\n  An array of objects representing manipulation options. Each object should have _only one_ of the following keys that corresponds to specific transformation:\n\n  - **resize (_object_)** -- An object of shape `{ width, height }`. Values correspond to the result image dimensions. If you specify only one value, the other will be calculated automatically to preserve image ratio.\n  - **rotate (_number_)** -- Degrees to rotate the image. Rotation is clockwise when the value is positive and counter-clockwise when negative.\n  - **flip (_string_)** -- `ImageManipulator.FlipType.{Vertical, Horizontal}`. Only one flip per transformation is available. If you want to flip according to both axes then provide two separate transformations.\n  - **crop (_object_)** -- An object of shape `{ originX, originY, width, height }`. Fields specify top-left corner and dimensions of a crop rectangle.\n\n- **saveOptions (_object_)** -- A map defining how modified image should be saved:\n  - **compress (_number_)** -- A value in range `0.0` - `1.0` specifying compression level of the result image. `1` means no compression (highest quality) and `0` the highest compression (lowest quality).\n  - **format (_string_)** -- `ImageManipulator.SaveFormat.{JPEG, PNG}`. Specifies what type of compression should be used and what is the result file extension. `SaveFormat.PNG` compression is lossless but slower, `SaveFormat.JPEG` is faster but the image has visible artifacts. Defaults to `SaveFormat.JPEG`.\n  - **base64 (_boolean_)** -- Whether to also include the image data in Base64 format.\n\n#### Returns\n\nReturns `{ uri, width, height }` where `uri` is a URI to the modified image (useable as the source for an `Image`/`Video` element), `width, height` specify the dimensions of the image. It can contain also `base64` - it is included if the `base64` saveOption was truthy, and is a string containing the JPEG/PNG (depending on `format`) data of the image in Base64--prepend that with `'data:image/xxx;base64,'` to get a data URI, which you can use as the source for an `Image` element for example (where `xxx` is 'jpeg' or 'png').\n\n### Basic Example\n\nThis will first rotate the image 90 degrees clockwise, then flip the rotated image vertically and save it as a PNG.\n\n```javascript\nimport React from 'react';\nimport { Button, View, Image } from 'react-native';\nimport { Asset } from 'expo-asset';\nimport * as ImageManipulator from 'react-native-image-manipulator';\n\nexport default class ImageManipulatorSample extends React.Component {\n  state = {\n    ready: false,\n    image: null,\n  };\n\n  componentDidMount() {\n    (async () =\u003e {\n      const image = Asset.fromModule(require('./assets/snack-icon.png'));\n      await image.downloadAsync();\n      this.setState({\n        ready: true,\n        image,\n      });\n    })();\n  }\n\n  render() {\n    return (\n      \u003cView style={{ flex: 1, justifyContent: 'center' }}\u003e\n        {this.state.ready \u0026\u0026 this._renderImage()}\n        \u003cButton title=\"Rotate and Flip\" onPress={this._rotate90andFlip} /\u003e\n      \u003c/View\u003e\n    );\n  }\n\n  _rotate90andFlip = async () =\u003e {\n    const manipResult = await ImageManipulator.manipulateAsync(\n      this.state.image.localUri || this.state.image.uri,\n      [{ rotate: 90 }, { flip: ImageManipulator.FlipType.Vertical }],\n      { compress: 1, format: ImageManipulator.SaveFormat.PNG }\n    );\n    this.setState({ image: manipResult });\n  };\n\n  _renderImage = () =\u003e {\n    return (\n      \u003cView style={{ marginVertical: 20, alignItems: 'center', justifyContent: 'center' }}\u003e\n        \u003cImage\n          source={{ uri: this.state.image.localUri || this.state.image.uri }}\n          style={{ width: 300, height: 300, resizeMode: 'contain' }}\n        /\u003e\n      \u003c/View\u003e\n    );\n  };\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpontusab%2Freact-native-image-manipulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpontusab%2Freact-native-image-manipulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpontusab%2Freact-native-image-manipulator/lists"}