Skip to content

Teeny tiny module for calculating aspect ratio from bounding box coordinates ✨

License

Notifications You must be signed in to change notification settings

harshzalavadiya/bbox-aspect-ratio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bounding Box Aspect Ratio

Calculate aspect ration from bounding box

🔧 Installation

npm i bbox-aspect-ratio

📦 Usage

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

About

Teeny tiny module for calculating aspect ratio from bounding box coordinates ✨

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published