0.3.0 • Published 4 years ago
@s9a/dab v0.3.0
dab
- Create images in any color
- Convert image filetypes
- Resize images
node usage
npm install @s9a/dabconst dab = require("@s9a/dab")dab(deets, callback=dab.terse)deets
properties
fromis a filename or color format- Default is
"#dab" - Supports
pnggiftifjpgwebpsvg - Supports hexes and named colors or
rgbhslwith commas
- Default is
tois the filename to save to- Default is like
[from]_[shape].png - Supports
pngtifjpgwebp
- Default is like
shapeis desired dimensions in pixels- Supports wtb formats
- Default is
960aka"960"aka"960x960"aka[960, 960]
create png from color
dab({
from: "#bae",
to: "bae.png",
shape: "1280x640",
})convert jpg to webp
dab({
from: "foto.jpg",
to: "foto.webp",
shape: "1280x640",
})callback
callbackmay be custom or presetcallbackdefaults todab.terse
dab({})dab({}, dab.verbose)dab({}, (err, did) => {
if (err) throw err
console.log(did)
})callback presets
dab.verboseverbose infodab.terseterse infodab.quietonly warnings or errorsdab.silentnothing
CLI
syntax
dab [from] [to] [shape]- supports the same properties as the node syntax
fromcan be a filename or color formattocan be a filename- shape Dimension syntax is widthxheight or just
widthfor square
hexes
- Good:
"#000"'#000'\#000"rgb(0, 0, 0)""black"'black'black - Fails:
#000rgb(0, 0, 0) - CLI sees # as comment if seen without quotes or backslash
- CLI honors alphabet hexes like
#bedasbedas shorthand but not likeb3d
flags
--help--silent--quiet--tersedefault--verbose
node npm npx
node installers provide node npm npx
versions are checkable via your command line
node -v
npm -v
npx -vCLI examples
temporary
npxlets you dab on the fly with the scoped package name@s9a/dab- Easy way to try dab without saving the package
npx @s9a/dab "#dab" dab.png 1280
npx @s9a/dab "#dab" dab.png 1280x640
npx @s9a/dab "lime" 1280
npx @s9a/dab "lime" 1280x640
npx @s9a/dab "rgb(0, 255, 0)" 1280x640project
- You can save
@s9a/dabas a project dependency - Recommended when you wanna dab in a project
- First create
package.jsonvianpm initor manually
npm install @s9a/dabnpx dab "#dab" dab.png 1280
npx dab "#dab" dab.png 1280x640
npx dab "lime" 1280
npx dab "lime" 1280x640
npx dab "rgb(0, 255, 0)" 1280x640clone
- Cloning the repo is another way to dab
- This'll create a folder where you can dab
git clone git@github.com:s9a/dab.git #team
git clone https://github.com/s9a/dab.git #guest
cd dab
npm install
npm testnpx . "#dab" dab.png 1280
npx . "#dab" dab.png 1280x640
npx . "lime" 1280
npx . "lime" 1280x640
npx . "rgb(0, 255, 0)" 1280x640global
- This is how to install
dabas global command - Recommended when you wanna dab anywhere and have access
- May need
--unsafe-permto build dependencies
npm install @s9a/dab --global #admin
sudo npm install @s9a/dab --global #userdab "#dab" dab.png 1280
dab "#dab" dab.png 1280x640
dab "lime" 1280
dab "lime" 1280x640
dab "rgb(0, 255, 0)" 1280x640uninstall whenever
npm uninstall @s9a/dab --global