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

129
Views
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 answers
Answer question

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 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!