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

failing to convert from webp to jpg #18

Open
aner87 opened this issue Nov 4, 2019 · 0 comments
Open

failing to convert from webp to jpg #18

aner87 opened this issue Nov 4, 2019 · 0 comments

Comments

@aner87
Copy link

aner87 commented Nov 4, 2019

Hello everybody,
I'm having hard time understanding how I can convert a WEBP to JPG format with this library.
Here's the code that I am trying out, attempting to get a chart I created with image-charts, saving it to WEBP (which it seems like working) and then converting it to JPG (which doesn't work...):

const fetch = require("node-fetch");
var webp = require('webp-converter');

fetch('https://image-charts.com/chart?chs=800x500&chd=a%3A9013.2091736%2C9163.2091736%2C9165.06157621%2C9161.66901514%2C9170.42788996%2C9169.43452831%2C9182.01273139%2C9194.16973332%2C9168.5367712%2C9186.19727611%2C9176.0191636%2C9179.57585269%2C9161.28960878%2C9239.28629898%2C9236.19102544%2C9268.5816066%2C9287.45653125%2C9285.54630386%2C9285.66476772%2C9350.08109775%2C9378.11735531%2C9335.07726903%2C9323.07942068%2C9311.25715813%7C1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%2C11%2C12%2C13%2C14%2C15%2C16%2C17%2C18%2C19%2C20%2C21%2C22%2C23%2C24&chxt=x%2Cy&chxr=1%2C8513%2C9878&chxl=0%3A%7C23%7C22%7C21%7C20%7C19%7C18%7C17%7C16%7C15%7C14%7C13%7C12%7C11%7C10%7C9%7C8%7C7%7C6%7C5%7C4%7C3%7C2%7C1%7C0&chls=5%2C0%2C0&chtt=BTC%2FUSD+Powered+by+%40crypto.rates&chts=C04F1D%2C20%2Cr&chco=C04F1D&chma=20%2C20%2C20%2C20&chg=0%2C50%2C3%2C5&chm=s%2CC04F1D%2C0%2C-1%2C15%7CB%2CFCECF4%2C0%2C0%2C0&cht=lc')
    .then(async res => {
        const dest = fs.createWriteStream('./lastPicW.webp');
        await res.body.pipe(dest);
        console.log("image saved as WEBP...")

        webp.dwebp('./lastPicW.webp', "./lastPic.jpg", "-o", function (status, error) {
            if (status == 100) {
                console.log("Image saved as JPG!")
            } else if (status == 101) {
                console.log("Saving as JPG...failed!")
            } else {
                //if conversion successful status will be '100'
                //if conversion fails status will be '101'
                console.log(status, error);
            }

        });
    }).catch(err => console.log("fetch err: " + err))

Any idea on what I'm doing wrong? Thanks =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant