You can generate image file of any size and byte.
You can specify vertical and horizontal size or number of bytes, or both.
$ node app --size 100,100 --byte 2kb
That way, a PNG file of that size will be created in ./images
.
Node.js is required.
This programming uses node-canvas
internally.
So it is essential to install the libraries that node-canvas
needs.
If you are a Mac user, you may be able to install it easily with Homebrew
.
For details please read the official document.
https://github.com/Automattic/node-canvas
$ npm i
This is now completely ready.
--size -s
Specify by width,height
or width*height
.
$ node app --size 100,60
--byte -b
$ node app --byte 200
That way, An PNG file of 200 bytes is created.
--byte 200 -> 200bytes
--byte 190b -> 190bytes
--byte 2kb -> 2048bytes(= 2 * 1024 = 2kb)
--byte 1.5mb -> 1572864bytes(= 1.5 * 1024 * 1024 = 1.5mb)
You can specify both.
$ node app -s 500,280 -b 900
A PNG file that satisfies both conditions is created.
--fill -f
Usually, a transparent image is created.
However, if this option is specified, an image filled with a specific color will be created.
$ node app -s 100,50 -b 900 -f
If you run $ node app --help
, you can see a list of available options.