0.1.4-alpha4 • Published 3 years ago

images-packer v0.1.4-alpha4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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
import * as ImagesPacker from 'images-packer'
// or
const ImagesPacker = require('images-packer')
  1. Create an array of objects with your images. All objects must contain width and height attributes.
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'
  }
]
  1. Pass created array of objects to a function
// 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
        })
0.1.4-alpha2

3 years ago

0.1.4-alpha3

3 years ago

0.1.4-alpha4

3 years ago

0.1.4-alpha1

3 years ago

0.1.3-alpha6

3 years ago

0.1.3-alpha7

3 years ago

0.1.3-alpha5

3 years ago

0.1.3-alpha4

3 years ago

0.1.3-alpha3

3 years ago

0.1.3-alpha2

3 years ago

0.1.3-alpha1

3 years ago

0.1.3-alpha

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago