Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

398
Views
¿Cómo puedo mostrar una imagen sin descargarla de una URL en NodeJS?

En NodeJS, utilicé el paquete llamado node-fetch , también para tomar la respuesta JSON, pero ¿qué tal una respuesta de imagen? ¿Cómo puedo hacer eso? En mis códigos actuales, solo guarda la imagen que no se muestra como PIL de python.

 var tr = "https://i.picsum.photos/id/866/200/300.jpg?hmac=rcadCENKh4rD6MAp6V_ma-AyWv641M4iiOpe1RyFHeI" export async function get_image() { const get_url = await fetch(tr) const image = get_url.body.pipe(fs.createWriteStream('./image.png')) } await get_image();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede obtener una imagen en formato Base64 y guardarla en una variable usando el módulo axios así:

 const axios = require('axios') const imageURL = 'https://i.picsum.photos/id/866/200/300.jpg?hmac=rcadCENKh4rD6MAp6V_ma-AyWv641M4iiOpe1RyFHeI'; (async ()=>{ // Get image Buffer from url and convert to Base64 const image = await axios.get(imageURL, {responseType: 'arraybuffer'}); const base64Image = Buffer.from(image.data).toString('base64'); // Do stuff with result... console.log(base64Image); })(); // Or if you prefer, a one liner (async ()=>{ const base64Image = Buffer.from((await axios.get(imageURL, {responseType: 'arraybuffer'})).data).toString('base64'); })();

Puede verificar si funcionó utilizando un sitio web para decodificar la cadena base64 en una imagen .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!