0.0.0 • Published 12 years ago
resize-logic v0.0.0
resize-logic 

Determines the correct dimensions for resizing and cropping images, without being attached to any particular tool
Usage
results = resize(options)
require('resize-logic') exports a function that takes a selection of options:
var resize = require('resize-logic')
var options = {
height: 200
, original: [400, 200]
, crop: true
}
var results = resize(options)options.original: the original dimensions of the image as an array, i.e.:[width, height]options.width: the target width of the resized image. Optional, but one ofheightorwidthmust be included.options.height: the target height of the resized image. Optional, but one ofheightorwidthmust be included.options.crop: whether or not to crop the image or just scale it. Defaults tofalse.options.smaller: whether to scale to handle the smallest of width/height or heighest, when both are supplied. Defaults totrue, orfalseifoptions.cropis enabled.
When called, the function returns a results object with the following properties:
{
"drawPosition": [-20, 0]
, "drawDimensions": [400, 200]
, "canvasDimensions": [360, 200]
}results.drawPosition
The x/y position to draw the image (where the origin is the top-left). Supplied
as an array, i.e. [x, y].
results.drawDimensions
The width and height to draw the image. Supplied as an array, i.e.
[width, height].
results.canvasDimensions
The width and height of the actual canvas to draw on. Supplied as an array,
i.e. [width, height]
License
MIT. See LICENSE.md for details.
0.0.0
12 years ago
