https://github.com/harshzalavadiya/bbox-aspect-ratio
Teeny tiny module for calculating aspect ratio from bounding box coordinates ✨
https://github.com/harshzalavadiya/bbox-aspect-ratio
aspect-ratio bbox boundingbox
Last synced: 3 months ago
JSON representation
Teeny tiny module for calculating aspect ratio from bounding box coordinates ✨
- Host: GitHub
- URL: https://github.com/harshzalavadiya/bbox-aspect-ratio
- Owner: harshzalavadiya
- License: mit
- Created: 2019-07-09T12:12:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-19T23:15:50.000Z (almost 4 years ago)
- Last Synced: 2025-01-29T17:25:54.523Z (5 months ago)
- Topics: aspect-ratio, bbox, boundingbox
- Language: TypeScript
- Homepage:
- Size: 1010 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bounding Box Aspect Ratio
Calculate aspect ration from bounding box
## 🔧 Installation
```sh
npm i bbox-aspect-ratio
```## 📦 Usage
```javascript
import { bBoxAspectRatio, calculateSize, SizeType } from "bbox-aspect-ratio";// Get aspect ratio
const topRight = [76.20742, 11.59426];
const bottomLeft = [76.86794, 11.95073];
const aspectRatio = bBoxAspectRatio([...topRight, ...bottomLeft]);
console.log(aspectRatio); // [1321, 713]// Calculate size by width
const sizeByWidth = calculateSize(aspectRatio, 50, SizeType.Width);
console.log(sizeByWidth); // 27 → w: 50, h: 27// Calculate size by height
const sizeByHeight = calculateSize(aspectRatio, 50, SizeType.Height);
console.log(sizeByWidth); // 93 → w: 93, h: 50
```