{"id":14384995,"url":"https://github.com/gre/gl-react-image","last_synced_at":"2025-03-25T09:30:52.236Z","repository":{"id":9271304,"uuid":"61455264","full_name":"gre/gl-react-image","owner":"gre","description":"Universal gl-react Image that implements resizeMode in OpenGL","archived":false,"fork":false,"pushed_at":"2022-12-10T20:27:42.000Z","size":2786,"stargazers_count":59,"open_issues_count":20,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T11:46:28.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gl-react-image.surge.sh","language":"JavaScript","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/gre.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":"2016-06-18T22:38:28.000Z","updated_at":"2024-09-01T15:48:26.000Z","dependencies_parsed_at":"2023-01-11T20:11:53.211Z","dependency_job_id":null,"html_url":"https://github.com/gre/gl-react-image","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gre%2Fgl-react-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gre","download_url":"https://codeload.github.com/gre/gl-react-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245435049,"owners_count":20614818,"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":[],"created_at":"2024-08-28T18:01:50.866Z","updated_at":"2025-03-25T09:30:51.745Z","avatar_url":"https://github.com/gre.png","language":"JavaScript","readme":"# gl-react-image ![](https://img.shields.io/npm/v/gl-react-image.svg) ![](https://img.shields.io/badge/gl--react-3-05F561.svg) ![](https://img.shields.io/badge/gl--react-dom%20%7C%20native-f90.svg)\n\nUniversal [gl-react](https://github.com/gre/gl-react) module **that implements [resizeMode prop](https://facebook.github.io/react-native/docs/image.html#resizemode)** in OpenGL.\n\n[-\u003e Example App \u003c-](https://gl-react-image.surge.sh/)\n\nThe library is called `gl-react-image` but barely anything can be the source, it can be a video, a canvas, another stack of effects,... (anything that gl-react support as a texture)\n\n```sh\nyarn add gl-react-image\n```\n\n```js\nimport GLImage from \"gl-react-image\";\nimport {Surface} from \"gl-react-dom\";// or \"gl-react-native\" or \"gl-react-expo\" or ..\n\n\u003cSurface ...\u003e\n  \u003cGLImage\n    source=\"http://i.imgur.com/tCatS2c.jpg\"\n    resizeMode=\"stretch\"\n  /\u003e\n\u003c/Surface\u003e\n```\n\n## `GLImage` Props\n\n- `source` **(required)**: the texture input. It can be an image URL or anything gl-react supports for textures.\n- `resizeMode`: `\"cover\" | \"stretch\" | \"contain\"` : This implement the exact same [React Native Image resizeMode prop](https://facebook.github.io/react-native/docs/image.html#resizemode) in OpenGL.\n- `center` and `zoom` props can be used with `resizeMode=cover` to define the cover crop position:\n  - `center`, an [x,y] array, defines the gravity of the crop *(x and y are in [0, 1] bound)*.\n  - `zoom` should be a value in **] 0 , 1 ]** bound. 1 means no zoom, more value is close to 0, more the zoom is important.\n- `width` and `height`: only provide if you also want a resize. (this is feeded to the gl-react Node width/height)\n\n## Example\n\n[-\u003e Example App \u003c-](https://gl-react-image.surge.sh/)\n\n```html\n\u003cGLImage\n  source=\"http://i.imgur.com/tCatS2c.jpg\"\n  resizeMode=\"stretch\"\n/\u003e\n```\n\nalternative syntax is to use only `source` via a `{ uri, width, height }` object.\n\n```html\n\u003cGLImage\n  source=\"http://i.imgur.com/tCatS2c.jpg\"\n  resizeMode=\"stretch\"\n/\u003e\n```\n\n```html\n\u003cGLImage\n  source=\"http://i.imgur.com/tCatS2c.jpg\"\n  resizeMode=\"contain\"\n/\u003e\n```\n\n```html\n\u003cGLImage\n  source=\"http://i.imgur.com/tCatS2c.jpg\"\n  resizeMode=\"cover\"\n/\u003e\n```\n\n```html\n\u003cGLImage\n  source=\"http://i.imgur.com/tCatS2c.jpg\"\n  resizeMode=\"cover\"\n  zoom={0.5}\n/\u003e\n```\n\n```html\n\u003cGLImage\n  source=\"http://i.imgur.com/tCatS2c.jpg\"\n  resizeMode=\"cover\"\n  zoom={0.44}\n  center={[ 1, 0.55 ]}\n/\u003e\n```\n\n### Web usage example\n\n```js\nimport React from \"react\";\nimport {render} from \"react-dom\";\nimport {Surface} from \"gl-react-dom\";\nimport GLImage from \"gl-react-image\";\n\nrender(\n  \u003cSurface width={300} height={300}\u003e\n    \u003cGLImage\n      source=\"http://i.imgur.com/tCatS2c.jpg\"\n    /\u003e\n  \u003c/Surface\u003e\n  , document.body\n))\n```\n\n### React Native usage example\n\n```js\nimport React from \"react\";\nimport {Image, View} from \"react-native\";\nimport {Surface} from \"gl-react-dom\";\nimport GLImage from \"gl-react-image\";\n\nexport default class Example extends Component {\n  static propTypes = {\n    src: PropTypes.string.isRequired,\n  };\n  render () {\n    return (\n      \u003cSurface style={{ width: 300, height: 300 }}\u003e\n        \u003cGLImage\n          source={src}\n        /\u003e\n      \u003c/Surface\u003e\n    );\n  }\n}\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgre%2Fgl-react-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgre%2Fgl-react-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgre%2Fgl-react-image/lists"}