Skip to content

jpalumickas/fit-with-aspect-ratio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.