question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This lib looks pretty handy, although it would be nice if we could pipe the image transformations directly to the browser with streams.

Something like this.


app.get("/my-dynamic-image", function (req, res) {
    new Jimp("lenna.png", function (err, image) {
         this.resize(512, 512); // resize
         this.pipe(res); // Send off.
    });
});

However I think that the api would be more intuative without forcing a callback into the Jimp constructor, and also making new optional.


app.get("/my-dynamic-image", function (req, res) {
    Jimp("lenna.png")
         .resize(512, 512)
         .pipe(res);
});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

26reactions
oliver-morancommented, Nov 3, 2015

This can be done using buffers:

var Jimp = require("jimp");

var express = require("express");
var app = express();

app.get("/my-dynamic-image", function(req, res){
    Jimp.read("lenna.png", function(err, lenna) {
        lenna.resize(64, 64).quality(60).getBuffer(Jimp.MIME_JPEG, function(err, buffer){
             res.set("Content-Type", Jimp.MIME_JPEG);
             res.send(buffer);
         });
    });
});

app.listen(3000);
2reactions
canvas-manikcommented, Nov 7, 2015

Can this be made dynamic for all files types like Jpeg, png, bmp? Like, you are using getBuffer(Jimp.MIME_JPEG,function… Can there be a generic input which can take the type of the input file?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Steam Support
Log in to your Steam account to get help with your Steam games, contact Steam Support, request refunds, and more. Help is also...
Read more >
Stream support - Microsoft Stream
No information is available for this page.
Read more >
StreamSupport (Java Platform SE 8 ) - Oracle Help Center
Low-level utility methods for creating and manipulating streams. This class is mostly for library writers presenting stream views of data structures; ...
Read more >
DIRECTV STREAM Customer Service & Support
Get support for your DIRECTV STREAM service, fix many of your issues online, and contact DIRECTV STREAM customer service.
Read more >
Streams | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found