{"id":4150,"url":"https://github.com/ihor/react-native-scalable-image","last_synced_at":"2025-05-16T19:05:16.056Z","repository":{"id":40693919,"uuid":"82981723","full_name":"ihor/react-native-scalable-image","owner":"ihor","description":"React Native Image component which scales width or height automatically to keep the original aspect ratio","archived":false,"fork":false,"pushed_at":"2021-05-12T14:51:32.000Z","size":34,"stargazers_count":314,"open_issues_count":15,"forks_count":67,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-26T02:34:22.810Z","etag":null,"topics":["aspect-ratio","component","image","react-native","reactjs","responsive","scalable","scales-height","scales-width"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-scalable-image","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/ihor.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-02-23T23:33:49.000Z","updated_at":"2024-04-10T07:29:23.000Z","dependencies_parsed_at":"2022-09-04T14:41:21.455Z","dependency_job_id":null,"html_url":"https://github.com/ihor/react-native-scalable-image","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihor%2Freact-native-scalable-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihor%2Freact-native-scalable-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihor%2Freact-native-scalable-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ihor%2Freact-native-scalable-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ihor","download_url":"https://codeload.github.com/ihor/react-native-scalable-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248607886,"owners_count":21132625,"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":["aspect-ratio","component","image","react-native","reactjs","responsive","scalable","scales-height","scales-width"],"created_at":"2024-01-05T20:17:02.651Z","updated_at":"2025-04-12T17:41:33.908Z","avatar_url":"https://github.com/ihor.png","language":"JavaScript","funding_links":[],"categories":["Components","JavaScript","Others"],"sub_categories":["UI"],"readme":"React Native Scalable Image\n===========================\nReact Native ```\u003cImage/\u003e``` component [does not keep the image aspect ratio](https://github.com/facebook/react-native/issues/858), which results in the image being stretched or cropped. ```react-native-scalable-image``` solves this problem by calculating the image size and resizing the image when rendering.\n\nThis library provides an ```\u003cImage/\u003e``` component which scales width or height automatically to keep the aspect ratio. It is useful when you don't know the aspect ratio in advance (e.g. user-uploaded content) but want to display the entire image and limit it only by width or height to fit the container component.\n\nThe following example creates an image which fits the full screen width and keeps the aspect ratio:\n\n ```jsx\nimport React from 'react';\nimport { Dimensions } from 'react-native';\nimport Image from 'react-native-scalable-image';\n\nconst image = (\n    \u003cImage\n        width={Dimensions.get('window').width} // height will be calculated automatically\n        source={{uri: '\u003cimage uri\u003e'}}\n    /\u003e\n);\n ```\n\n\nInstall\n=======\n```npm install react-native-scalable-image --save```\n\n\nUsage\n=====\n\nSpecify width or height which may be calculated dynamically like in the example above. All other props are the same as in regular [React Native ```\u003cImage/\u003e``` component](https://facebook.github.io/react-native/docs/image.html).\n\n## props\n\n| name          | type            | default                     | description                                                               |\n| ------------- | --------------- | --------------------------- | --------------------------------------------------------------------------|\n| `height`      | number          | none                        | Maximum image height                                                      |\n| `width`       | number          | none                        | Maximum image width                                                       |\n| `background`  | boolean         | false                       | Set to true when used as a background                                     |\n| `component`   | React.ReactNode | none                        | Custom image component                                                    |\n| `onPress`     | function        | none                        | onPress callback                                                          |\n| `onSize`      | function        | none                        | Is called with ```{ width, height }``` as the first arg once image size is calculated |\n\nVersions\n========\nThe latest major version of `react-native-scalable-image` is implemented with hooks. If you are using a pre-hooks React version please use `react-native-scalable-image` version `0.5.1`\n\n| React Version | Scalable Image Version |\n| ------------- | ---------------------- |\n|  \u003c 16.8       |   0.5.1                |\n| \u003e= 16.8       | \u003e 1.0.0                |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihor%2Freact-native-scalable-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fihor%2Freact-native-scalable-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fihor%2Freact-native-scalable-image/lists"}