Tarikgambar
Simple image download command line tool & module for node.js. Supports image/png
, image/gif
, image/jpeg
, image/webp
types.
Tested with Node v4 and v6.
Installing
As command-line tool
npm install -g tarikgambar
As regular module
npm install tarikgambar
Breaking changes from v0 to v1
- Removed
outputDir
andfilename
from configuration object. You should useoutputPath
instead.
Configuration
url
: (String) - URL of the target image file.outputType
: (String) - This value should be eitherstream
orfile
. Default tostream
if not defined.outputPath
: (String) - Path to the output file, will fail if the directory is not exists. This field is not used ifoutputType
isstream
.
API
tarikgambar.pull(options, callback)
Call callback on completition with error or value that contains path to a file or response stream depending on options.outputType
value.
Parameters:
options
: (Object) - Download configuration.callback
: (Function(Error, String|Response) - Callback function to be called on completition.
Example 1 (stream):
tarikgambar;
Example 2 (path):
const options = url: 'http://example.com/path/to/some/image.png' outputType: 'file' outputPath: '/home/winter/downloaded.png'; tarikgambar;
tarikgambar.pullAsync(options) -> Promise<String|Response>
Return promise that will be rejecter or resolve to either path to a file or response stream depending on options.outputType
value.
Example 1 (stream):
tarikgambar;
Example 2 (path):
const options = url: 'http://example.com/path/to/some/image.png' outputType: 'file' outputPath: '/home/winter/downloaded.png'; tarikgambar;