JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1075
  • Score
    100M100P100Q101339F
  • License MIT

Image aspect ratio utility

Package Exports

  • aspectratio

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aspectratio) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

aspectratio

Build status NPM downloads NPM version Node version Dependency status

Image aspect ratio utilities.

Install

npm install aspectratio --save

API

var aspect = require('aspectratio');

fixed(integer width, integer height, string ratio)

Apply a fixed aspect ratio without distoring the image.

  • integer width - original image width
  • integer height - original image height
  • string ratio - new image ratio

Return

This will return an Array of four values:

  1. integer x - top lef x coordinate
  2. integer y - top lef y coordinate
  3. integer width - new image width
  4. integer height - new image height

Example

var crop = aspect.fixed(2048, 768, '4:3');
// [512, 768, 1024, 768]

Cropp with fixed ratio

MIT License