Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
array of 9 digit numbers convert to jpg

I want to make a nodejs application that takes a 9 digit numbers array which represent an rgb pixel so 123456789 represent r:123, g:456, b:789 and convert it to jpg image.

so example of array is :

let pixels = [
  '000115166', '000115164', '000115164', '000115166', '000115166',
  '000115166', '000115166', '000115164', '000115164', '000115166',
  '000115166', '000115166', '000115166', '000115164', '000115166',
  '000115166', '000115166', '000115166', '000115166', '000115166',
  '000115164', '000115166', '000115166', '000115164', '000115164',
  '000114168', '000115166', '000114168', '000115164', '000114168']

is there a way to do that in nodejs app?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Using sharp npm in node.js we can convert images using RGB color hope this code will help you

 const sharp = require("sharp"); const fs = require("fs"); const path = require("path"); const { v4: uuidv4 } = require("uuid"); const convertImage = async () => { let pixels = [ "198115166", "000115164", "000115164", "000115166", "000115166", "000115166", "000115166", "000115164", "000115164", "000115166", "000115166", "000115166", "000115166", "000115164", "000115166", "000115166", "000115166", "000115166", "000115166", "000115166", "000115164", "000115166", "000115166", "000115164", "000115164", "000114168", "000115166", "000114168", "000115164", "000114168", ]; const rgbData = []; pixels.forEach((e) => { const obj = { r: e.substring(0, 3), g: e.substring(3, 6), b: e.substring(6, 9), }; rgbData.push(obj); }); const imagefolderpath = path.resolve(`${__dirname}`, "Images"); for (const color of rgbData) { const filename = `${uuidv4()}.jpeg`; await sharp({ create: { width: 48, height: 48, channels: 4, background: { ...color }, }, }).toFile(filename); } }; convertImage();
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda