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

234
Views
How to Force Download to use JPEG instead of JFIF

I'm creating a feature to export a graph from my website. On my local machine the images are being downloaded as JFIF's on my coworkers the images are properly being downloaded as JPEG's. I am aware that I can configure my local machine to change the extension. However, I don't want non-technical users to have to go through this process. Is there a way to ensure that images are downloaded on any machine as JPEG's?

Here is my code

const downloadGraph = () => {
  const element = document.getElementById('unique-id') as HTMLCanvasElement;
  saveImage(element, 'Title');
}

const saveImage = (canvas: HTMLCanvasElement, fileName: string) => {
   const url = canvas.toDataURL('image/jpeg', 1.0);
   download(url, fileName, )
}

const download = (url: string, fileName: string) => {
  const link = document.createElement("a");
  link.setAttribute("href", url);
  link.setAttribute("download", fileName);
  link.style.visibility = 'hidden';
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}


about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Modify the fileName parameter (in both cases)

fileName.slice(0,fileName.lastIndexOf('.'))+'.jpg'
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!