Package Exports
- compute-size
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 (compute-size) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
compute-size
Helper tool for resizing the things.
☁️ Installation
$ npm i --save compute-size
📋 Example
const computeSize = require("compute-size");
console.log(computeSize({
// Wanted size
width: 10
// 40% of the screen height
, height: "40%"
}, {
// Object width (e.g. an image)
width: 10
// ..and the height
, height: 50
}, {
screen_size: {
width: 100
, height: 200
},
preserve_aspect_ratio: false
}));
// { width: 10, height: 80 }
console.log(computeSize({
// Wanted size
width: 10
// 40% of the screen height
, height: "40%"
}, {
// Object width (e.g. an image)
width: 10
// ..and the height
, height: 50
}, {
screen_size: {
width: 100
, height: 200
}
}));
// { width: 10, height: 50 }
console.log(computeSize({
// Wanted size
height: "100%"
}, {
width: 10
, height: 50
}, {
screen_size: {
width: 100
, height: 400
}
}));
// { width: 80, height: 400 }
📝 Documentation
computeSize(wantedSize, realSize, options)
Computes a wanted size based on the object, pixel and screen sizes.
Params
- Object
wantedSize
: An object containing the following fields: width
(Number): The wanted width.height
(Number): The wanted height.- Object
realSize
: An object containing the following fields: width
(Number): The existing object width (e.g. an image).height
(Number): The existing object height (e.g. an image).- Object
options
: An object containing the following fields: screen_size
(Object): The screen size (defaults to terminal width and height):width
(Number): The screen width.height
(Number): The screen height.px_size
(Object): The pixel size.width
(default:1
)height
(default:1
)preserve_aspect_ratio
(Boolean): Iffalse
, the aspect ratio will not be preserved (default:true
).fit_screen
(Boolean): Iffalse
, the result size will not fit to screen (default:true
).
Return
- Object The result size:
width
(Number): The computed width.height
(Number): The computed height.
😋 How to contribute
Have an idea? Found a bug? See how to contribute.
💰 Donations
Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. 🚀
PayPal donations are appreciated too! Each dollar helps.
Thanks! ❤️
💫 Where is this library used?
If you are using this library in one of your projects, add it in this list. ✨
image-to-ascii
—A Node.JS module that converts images to ASCII art.