Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/traviswimer/resize-crop.js
Make images a specific size without distorting the aspect ratio. Resizes as close as possible and crops the rest.
https://github.com/traviswimer/resize-crop.js
Last synced: 1 day ago
JSON representation
Make images a specific size without distorting the aspect ratio. Resizes as close as possible and crops the rest.
- Host: GitHub
- URL: https://github.com/traviswimer/resize-crop.js
- Owner: traviswimer
- License: mit
- Created: 2014-03-19T22:56:13.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-16T08:01:05.000Z (over 9 years ago)
- Last Synced: 2024-12-06T23:21:13.017Z (21 days ago)
- Language: JavaScript
- Size: 159 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# resize-crop.js [![Build Status](https://travis-ci.org/traviswimer/resize-crop.js.png?branch=master)](https://travis-ci.org/traviswimer/resize-crop.js) [![Coverage Status](https://coveralls.io/repos/traviswimer/resize-crop.js/badge.png)](https://coveralls.io/r/traviswimer/resize-crop.js)
> Make images a specific size without distorting the aspect ratio. Resizes as close as possible and crops the rest.
## Installation
```shell
npm install resize-crop
```## Example
```javascript
var resizeCrop = require('resize-crop');resizeCrop(
{
format: 'jpg',
src: 'tests/images/myImageToBeResized.png',
dest: 'tests/tmp/resized_image.jpg',
height: 250,
width: 250,
gravity: "center"
},
function( err, filePath ){
// do something
}
);
```## Documentation
### options.src
* REQUIRED OPTION
* Type: `String`
* Description: Sets the path for the image you would like to convert.### options.dest
* REQUIRED OPTION
* Type: `String`
* Description: Sets the path for the image you would like to create.### options.height
* REQUIRED OPTION
* Type: `integer`
* Description: Sets the height in pixels to be used for the output image.### options.width
* REQUIRED OPTION
* Type: `integer`
* Description: Sets the width in pixels to be used for the output image.### options.format
* Type: `String`
* Default: `"png"`
* Description: Sets the image type to output. Supporst any image format supported by [imagemagick](https://github.com/rsms/node-imagemagick)### options.gravity
* Type: `string`
* Description: Determines the part of the image that will be removed during cropping. For example, `"center"` will try to keep the centermost part of the image and only remove the furthest edges.