Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Error Callback and Changed console.log() #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

# Created by https://www.gitignore.io/api/node

### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity


# End of https://www.gitignore.io/api/node
92 changes: 54 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ var webp=require('webp-converter');

//cwebp(input,output,option,result_callback)

webp.cwebp("input.jpg","output.webp","-q 80",function(status)
webp.cwebp("input.jpg","output.webp","-q 80",function(err, status)
{
//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};
});


Expand All @@ -53,11 +55,13 @@ var webp=require('webp-converter');

//dwebp(input,output,option,result_callback)

webp.dwebp("input.webp","output.jpg","-o",function(status)
webp.dwebp("input.webp","output.jpg","-o",function(err, status)
{
//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};
});

```
Expand All @@ -75,11 +79,13 @@ var webp=require('webp-converter');

//gwebp(input,output,option,result_callback)

webp.gwebp("input.gif","output.webp","-q 80",function(status)
webp.gwebp("input.gif","output.webp","-q 80",function(err, status)
{
//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};
});


Expand All @@ -101,11 +107,13 @@ var webp=require('webp-converter');

//webpmux_add(input,output,option_profile,set_option,result_callback)

webp.webpmux_add("input.webp","output.webp","image_profile.icc","icc",function(status){
webp.webpmux_add("input.webp","output.webp","image_profile.icc","icc",function(err, status){

//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};

});

Expand All @@ -126,11 +134,13 @@ var webp=require('webp-converter');

//webpmux_extract(input,output,option,result_callback)

webp.webpmux_extract("input.webp","output.icc","icc",function(status){
webp.webpmux_extract("input.webp","output.icc","icc",function(err, status){

//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};

});

Expand All @@ -151,11 +161,13 @@ var webp=require('webp-converter');

//webpmux_strip(input,output,option,result_callback)

webp.webpmux_strip("input.webp","ouput.webp","icc",function(status){
webp.webpmux_strip("input.webp","ouput.webp","icc",function(err, status){

//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};

});

Expand All @@ -168,18 +180,18 @@ webp.webpmux_strip("input.webp","ouput.webp","icc",function(status){

var webp=require('webp-converter');

//pass input images(.webp image) path with FRAME_OPTIONS, as array,ouput image will be animated .webp image
//pass input images(.webp image) path with FRAME_OPTIONS, as array,ouput image will be animated .webp image


/*FRAME_OPTIONS

-file_i +di[+xi+yi[+mi[bi]]]

e.g -frame one.webp +100 -frame two.webp +100+50+50 -frame three.webp +100+50+50+1+b
e.g -frame one.webp +100 -frame two.webp +100+50+50 -frame three.webp +100+50+50+1+b

Where: file_i is the i'th frame (WebP format), xi,yi specify the image offset for this frame,
di is the pause duration before next frame, mi is the dispose method for this frame (0 for NONE or 1 for BACKGROUND) and bi is the blending method for this frame (+b for BLEND or -b for NO_BLEND).
Argument bi can be omitted and will default to +b (BLEND). Also, mi can be omitted if bi is omitted and will default to 0 (NONE). Finally,
Where: file_i is the i'th frame (WebP format), xi,yi specify the image offset for this frame,
di is the pause duration before next frame, mi is the dispose method for this frame (0 for NONE or 1 for BACKGROUND) and bi is the blending method for this frame (+b for BLEND or -b for NO_BLEND).
Argument bi can be omitted and will default to +b (BLEND). Also, mi can be omitted if bi is omitted and will default to 0 (NONE). Finally,
if mi and bi are omitted then xi and yi can be omitted and will default to +0+0.

-loop n
Expand All @@ -188,7 +200,7 @@ e.g 10

Loop the frames n number of times. 0 indicates the frames should loop forever. Valid range is 0 to 65535 [Default: 0 (infinite)].

-bgcolor A,R,G,B
-bgcolor A,R,G,B

e.g 255,255,255,255

Expand All @@ -199,11 +211,13 @@ Background color of the canvas. Where: A, R, G and B are integers in the range 0

var input=["./frames/tmp-0.webp +100","./frames/tmp-1.webp +100+50+50","./frames/tmp-2.webp +100+50+50+1+b"];

webp.webpmux_animate(input,"anim_container.webp","10","255,255,255,255",function(status)
webp.webpmux_animate(input,"anim_container.webp","10","255,255,255,255",function(err, status)
{
//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};
});


Expand All @@ -219,11 +233,13 @@ var webp=require('webp-converter');

//webpmux_getframe(input,ouput,frame number,result_callback)

webp.webpmux_getframe("anim_container.webp","output.webp","2",function(status){
webp.webpmux_getframe("anim_container.webp","output.webp","2",function(err, status){

//if exicuted successfully status will be '100'
//if exicuted unsuccessfully status will be '101'
console.log(status);
//if executed successfully status will be '100'
//if executed unsuccessfully status will be '101'
if (!err) {
console.log(status);
};

});

Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "webp-converter",
"version": "2.1.6",
"version": "2.1.7",
"description": "A small node.js library for converting any image to webp file format or converting webp image to any image file format.",
"main": "webpconverter.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"node app.js"
"start": "node app.js"
},
"repository": {
"repository": {
"type": "git",
"url": "https://github.com/scionoftech/webp-converter.git"
},
Expand Down Expand Up @@ -43,5 +43,8 @@
"frames/"
],
"author": "scionoftech",
"license": "MIT"
"license": "MIT",
"dependencies": {
"debug": "^2.6.0"
}
}
Loading