fit-with-aspect-ratio
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

fit-with-aspect-ratio

Fit a original dimensions within a max/min boundaries while keeping its original aspect ratio

This package uses fit-box under the hood with additional changes, like ability to specify minimum dimensions to scale down.

Installation

yarn add fit-with-aspect-ratio

Usage

import fitWithAspectRatio from 'fit-with-aspect-ratio';

const { width, height } = fitWithAspectRatio({
  originalWidth: 300,
  originalHeight: 400,
  maxWidth: 100,
  maxHeight: 30,
  minWidth: 10,
  minHeight: 10,
})

License

The package is available as open source under the terms of the MIT License.

Package Sidebar

Install

npm i fit-with-aspect-ratio

Weekly Downloads

5

Version

0.1.1

License

MIT

Unpacked Size

11.5 kB

Total Files

10

Last publish

Collaborators

  • jpalumickas