# images-packer

> JS Lib to fit images in box in a most elegant way.

Latest version **0.1.4-alpha4** (published 2021-06-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install images-packer
pnpm add images-packer
yarn add images-packer
bun add images-packer
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4-alpha4 |
| Published | 2021-06-29 |
| First published | 2021-06-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrey Suvorov |
| Maintainers | andreysuvorov |

## Links

- npm: https://www.npmjs.com/package/images-packer
- Repository: https://github.com/andreysuworow/images-packer
- Homepage: https://github.com/andreysuworow/images-packer#readme
- Issues: https://github.com/andreysuworow/images-packer/issues
- npm.io page: https://npm.io/package/images-packer

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Recent versions

- 0.1.4-alpha4 (latest) — 2021-06-29
- 0.1.4-alpha3 — 2021-06-29
- 0.1.4-alpha2 — 2021-06-29
- 0.1.4-alpha1 — 2021-06-29
- 0.1.3-alpha7 — 2021-06-18
- 0.1.3-alpha6 — 2021-06-17
- 0.1.3-alpha5 — 2021-06-17
- 0.1.3-alpha4 — 2021-06-17
- 0.1.3-alpha3 — 2021-06-17
- 0.1.3-alpha2 — 2021-06-17
- 0.1.3-alpha1 — 2021-06-17
- 0.1.3-alpha — 2021-06-17
- 0.1.2 — 2021-06-17
- 0.1.1 — 2021-06-17
- 0.1.0 — 2021-06-17

## README

# Images-Packer
JS Lib to fit images in box in a most elegant way.

## How to use
### Installation
If you are using NPM:
`npm install images-packer`

Or if you are using Yarn:
`yarn add images-packer`

### Usage
1. Import package
```javascript
import * as ImagesPacker from 'images-packer'
// or
const ImagesPacker = require('images-packer')
```
2. Create an array of objects with your images. All objects *must* contain `width` and `height` attributes.
```javascript
let blocks = [
  {
    width: 749,
    height: 500,
    url: 'https://example.com/img1.jpg'
  },
  {
    width: 2436,
    height: 1125,
    url: 'https://example.com/img2.jpg'
  },
  {
    width: 2152,
    height: 66,
    url: 'https://example.com/img3.jpg'
  },
  {
    width: 35,
    height: 35,
    url: 'https://example.com/img4.jpg'
  }
]
```
3. Pass created array of objects to a function
```javascript
// Get optimal packing variant
let packedImages = ImagesPacker.fit(blocks,
        {
          containerWidth: 640,
          containerHeight: 440
        })
        
// Get all packing variants
let packedImagesVariants = ImagesPacker.getFitVariants(blocks,
        {
          containerWidth: 640,
          containerHeight: 440
        })
```

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