A
A
atumbochka2021-12-13 20:23:37
JavaScript
atumbochka, 2021-12-13 20:23:37

How to change the parameters of an image received with Node.js?

I'm getting an image using a server on Express:
<img src="/image1">

app.get("/image1", (req, res) => {
    res.sendFile(path.join(__dirname, "IMAGES", "1.jpg"));
});

But when you try to change the height or width of the image in the script file, nothing happens. Yes, I can change this in the HTML file itself, but I need it in the js file. I know about imagemagick and sharp, but I don't need to resize the image in a fixed way, but based on the size of the browser window, and in Node I don't have access to DOM elements.
Probably, the solution to the problem is very simple, but I have not encountered this before, and I could not google anything

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question