Follow

code inside (nodejs) 

// @minervissa Here you go! Probably not the best code but it works.

const express = require("express");
const pngStringify = require("console-png");
const sharp = require("sharp");
const fs = require("fs");
const app = express();
app.get("/:s", async (req, res, next) => {
try {
const [h, w] = decodeURIComponent(req.params.s).trim().split(/\D+/);
pngStringify(
await sharp("shork.png")
.resize(Math.floor(Math.min(+w, 2 * +h) || 24))
.png()
.toBuffer(),
function (err, string) {
if (err) next(err);
res.send("\x1b[48;5;231m\x1b[H\x1b[2J\x1b[3J" + string + "\x1b[H");
}
);
} catch (e) {
next(e);
}
});
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});

code inside (nodejs) 

@easrng wowwww you even made it go from a .png! I thought you hardcoded the escape sequences for each pixel into an array or something

This is awesome!

Sign in to participate in the conversation
Cybrespace

cybrespace: the social hub of the information superhighway jack in to the mastodon fediverse today and surf the dataflow through our cybrepunk, slightly glitchy web portal support us on patreon or liberapay!