-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hans Kristian Flaatten
committed
Apr 10, 2015
1 parent
0fc4096
commit 06bbe19
Showing
1 changed file
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
# node-aspectratio | ||
Image aspect ratio utility | ||
# aspectratio | ||
|
||
[![Build status](https://img.shields.io/wercker/ci/55281116a26c78542c01d251.svg "Build status")](https://app.wercker.com/project/bykey/90dda5965d63c43c484b2e29c7d4ba92) | ||
[![NPM downloads](https://img.shields.io/npm/dm/aspectratio.svg "NPM downloads")](https://www.npmjs.com/package/aspectratio) | ||
[![NPM version](https://img.shields.io/npm/v/aspectratio.svg "NPM version")](https://www.npmjs.com/package/aspectratio) | ||
[![Node version](https://img.shields.io/node/v/aspectratio.svg "Node version")](https://www.npmjs.com/package/aspectratio) | ||
[![Dependency status](https://img.shields.io/david/turistforeningen/node-aspectratio.svg "Dependency status")](https://david-dm.org/turistforeningen/node-aspectratio) | ||
|
||
Image aspect ratio utilities. | ||
|
||
[![Join the chat at https://gitter.im/Turistforeningen/node-s3-uploader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Turistforeningen/node-s3-uploader) | ||
|
||
## Install | ||
|
||
``` | ||
npm install aspectratio --save | ||
``` | ||
|
||
## API | ||
|
||
``` | ||
var aspect = require('aspectratio'); | ||
``` | ||
|
||
### fixed(**integer** `height`, **integer** `width`, **string** `ratio`) | ||
|
||
Apply a fixed aspect `ratio` without distoring the image. | ||
|
||
* **integer** `height` - original image height | ||
* **integer** `width` - original image width | ||
* **string** `ratio` - new image ratio | ||
|
||
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 | ||
|
||
![Cropp with fixed ratio](https://docs.google.com/drawings/d/1Lu8eLqcjjlI0YL7Q-YHg0ttjRC8I8Vkwq6PVXRgxNUo/pub?w=960&h=720) | ||
|
||
```javascript | ||
var crop = aspect.fixed(2048, 768, '4:3'); | ||
// [512, 768, 1024, 768] | ||
``` | ||
|
||
## [MIT License](https://github.com/Turistforeningen/node-s3-uploader/blob/master/LICENSE) | ||
|