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

134
Views
Converting png thumbnail to jpg

I have a png thumbnail with base64 data. I am trying to convert it to jpeg thumbnail. I am not sure what am I doing wrong. My current item has a blank thumbnail

var canvas = document.createElement('canvas');
canvas.id = currItem.Id + '_1';
canvas.width = currItem.ThumbnailInfo[0].Width;
canvas.height = currItem.ThumbnailInfo[0].Height;
var ctx = canvas.getContext('2d');

var p = new Promise((resolve, reject) => {

  var img = new Image();
  img.src = currItem.ThumbnailInfo[0].Thumbnail;
  img.onload = async function () {
    await ctx!.drawImage(img, 0, 0, canvas.width, canvas.height);
    var imageData = ctx?.getImageData(0, 0, canvas.width, canvas.height);
    ctx?.fillRect(0, 0, canvas.width, canvas.height);
    //var imageData = canvas.toDataURL();
    var imagejpeg = canvas.toDataURL('image/jpeg');
    resolve(imagejpeg);
  }
});

let imagejpgeg2 = await p;
currItem.ThumbnailInfo[0].Thumbnail = imagejpeg;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You may use Javascript JIMP Library to process Images.(PNG to JPG) you should take a look at https://www.npmjs.com/package/jimp

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!