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

Server-side result saving in JPEG? #139

Open
Renatico opened this issue Feb 10, 2014 · 2 comments
Open

Server-side result saving in JPEG? #139

Renatico opened this issue Feb 10, 2014 · 2 comments

Comments

@Renatico
Copy link

Please, anybody! Who can answer my question: Can I save the modified image via CamanJS in a format of JPG/JPEG? By default, the module saves the pictures using the algorithm of PNG. It would be wrong if we just save files with the extension of .jpg because the file's algorithm is PNG. Can anybody help me?

@coagulant
Copy link

Here is what I managed to come up with

var fs = require('fs');
Caman(src, function () {
    var caman = this;
    this.render(function () {
        var out = fs.createWriteStream(dst);
        var stream = caman.canvas.createJPEGStream({
            quality : 90
        });
        stream.pipe(out);
    });
});

src and dst are source and destination files.

Probably this should be built-in Caman API, becasue this low-lvel abstraction directly from canvas library.

@Renatico
Copy link
Author

Thank you, Coagulant, very much! Your solution works for me!

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

2 participants