rc

resize-crop

Make images a specific size without distorting the aspect ratio. Resizes as close as possible and crops the rest.

Showing:

Popularity

Downloads/wk

7

GitHub Stars

2

Maintenance

Last Commit

8yrs ago

Contributors

1

Package

Dependencies

3

Size (min+gzip)

5.1KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

resize-crop.js Build Status Coverage Status

Make images a specific size without distorting the aspect ratio. Resizes as close as possible and crops the rest.

Installation

npm install resize-crop

Example

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

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial