# react-native-image-size

> Get original image size (iOS + Android)

Latest version **1.1.6** (published 2023-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-image-size
pnpm add react-native-image-size
yarn add react-native-image-size
bun add react-native-image-size
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2023-10-13 |
| First published | 2019-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Ivan Sorokin |
| Maintainers | exist-fragger |
| Keywords | react, react-native, image, size, dimensions, resolution, width, height, android, ios |

## Links

- npm: https://www.npmjs.com/package/react-native-image-size
- Repository: https://github.com/eXist-FraGGer/react-native-image-size
- Homepage: https://github.com/eXist-FraGGer/react-native-image-size#readme
- Issues: https://github.com/eXist-FraGGer/react-native-image-size/issues
- npm.io page: https://npm.io/package/react-native-image-size

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.6 (latest) — 2023-10-13
- 1.1.5 — 2023-09-20
- 1.1.3 — 2019-10-03
- 1.1.2 — 2019-06-16
- 1.1.1 — 2019-02-20
- 1.1.0 — 2019-02-19
- 1.0.1 — 2019-02-19
- 1.0.0 — 2019-02-19

## README

## react-native-image-size (iOS + Android)

[![NPM version](https://badge.fury.io/js/react-native-image-size.svg)](http://badge.fury.io/js/react-native-image-size)

Android 4.0 (API level 14) introduced the ability to get original image size.

iOS uses Image.getSize https://facebook.github.io/react-native/docs/image#getsize


### Installation

Download via NPM

```shell
npm i -S react-native-image-size
```

Download via Yarn

```shell
yarn add react-native-image-size
```

Afterward make sure to rebuild app, not just refresh bundler.

## Linking (for React Native <= 0.59 only, React Native >= 0.60 skip this as auto-linking should work)

**-- Automaticaly --**

Link, either via `react-native link` or manually

```shell
react-native link react-native-image-size
```

**-- Manually --**

#### android/settings.gradle
```diff
+include ':react-native-image-size'
+project(':react-native-image-size').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-size/android')
```
#### android/app/build.gradle
```diff
dependencies {
  ...
+  implementation project(':react-native-image-size')
  ...
}
```
#### android/app/src/main/java/.../MainApplication.java
```diff
+import com.existfragger.rnimagesize.RNImageSizePackage;
...
@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<~>asList(
-    new MainReactPackage()
+    new MainReactPackage(),
+    new RNImageSizePackage()
  );
}
```

### How to use

```js
import ImageSize from 'react-native-image-size'
...
ImageSize.getSize(uri).then(size => {
    // size.height
    // size.width
})
```

You can also use async/await, if you would prefer.

```js
import ImageSize from 'react-native-image-size'
...
foo = async () => {
  const { width, height } = await ImageSize.getSize(uri);
  // do stuff with width and height
}
```

---
_Source: https://npm.io/package/react-native-image-size · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
