This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

aspecter
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Aspecter

A utility module for Node & Browser that calculates aspect ratio and decimal fraction based on width and height and alongside provides normalized aspect.

The normalizedAspect result contains information for intended aspect ratio of that resolution. Many film/video creators do rendering at some weird resolutions, so normalized aspect will be the intended choice.


Installation (pick one)

  • npm i aspecter
  • yarn add aspecter

Usage

You may hard-code width/height or grab it from some source. (e.g. video, image) If you have some weird resolution, normalizedAspect should be what you're actually looking for.


TypeScript

import { aspecter } from 'aspecter'

const aspecterResult = aspecter(1280, 536)

Node

const { aspecter } = require('aspecter')

const aspecterResult = aspecter(1280, 536)

Browser

<!-- PENDING CDN SUBMISSIONS -->
<script src="path/to/aspecter.js"></script>
<script>
  const aspecterResult = aspecter(1280, 536)
</script>

Output

Same resolution was used in all examples above, so the result will be the same.

// -- console.log output --
{
  resolution: [1280, 536],
  originalAspect: {
    ratio: [160, 67],
    decimal: 2.38
  },
  normalizedAspect: {
    ratio: [21, 9],
    decimal: 2.33
  }
}

Package Sidebar

Install

npm i aspecter

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

8.78 kB

Total Files

8

Last publish

Collaborators

  • dvlden