# @renditions/get-img-sizes

> Generate string for HTML image sizes attribute.

Latest version **0.0.5** (published 2019-09-07) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @renditions/get-img-sizes
pnpm add @renditions/get-img-sizes
yarn add @renditions/get-img-sizes
bun add @renditions/get-img-sizes
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2019-09-07 |
| First published | 2019-09-07 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stef |
| Maintainers | srilq |
| Keywords | responsive image, responsive images, images, image, sizes |

## Links

- npm: https://www.npmjs.com/package/@renditions/get-img-sizes
- Repository: https://github.com/renditions/get-img-sizes
- Homepage: https://github.com/renditions/get-img-sizes#readme
- Issues: https://github.com/renditions/get-img-sizes/issues
- npm.io page: https://npm.io/package/@renditions/get-img-sizes

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2019-09-07
- 0.0.4 — 2019-09-07
- 0.0.3 — 2019-09-07
- 0.0.2 — 2019-09-07
- 0.0.1 — 2019-09-07

## README

# @renditions/get-img-sizes

[![npm version](https://img.shields.io/npm/v/@renditions/get-img-sizes.svg?style=flat-square)](https://www.npmjs.com/package/@renditions/get-img-sizes) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

> Generate string for HTML image sizes attribute.

## Install

```sh
npm install @renditions/get-img-sizes
```

## Usage

```js
import getImgSizes from '@renditions/get-img-sizes'

const sizes = getImgSizes({
  defaultImageWidth: '100vw',
  breakpoints: [
    {
      viewportMinWidth: '960px',
      imageWidth: '50vw'
    },
    {
      viewportMinWidth: '480px'
    }
  ]
})

console.log(sizes)
```

The above code logs the following string to the console:

```
(min-width: 960px) 50vw,(min-width: 480px) 100vw,100vw
```

### Using with React

```jsx
import React from 'react'
import getSizes from '@renditions/get-img-sizes'

const Image = ({ width, ...rest }) => {
  const sizes = getSizes({ defaultImageWidth: width })

  return <img sizes={sizes} {...rest} />
}
```

---
_Source: https://npm.io/package/@renditions/get-img-sizes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
