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

117
Views
Display NEF and other raw images in browser via img tag

I want to display images from filesystem could be jpeg, png, nef, raw, svg etc. in browser. Some of these types like nef, raw are not natively supported by browser and I want to convert them to jpeg (and also to compress it in size) and display it. Below is my (not working) code. I have googled extensively and could not find a way to perform the conversion. The below code ends up triggering onerror callback in Image. Im a relative newbie to JS and would appreciate help/apointers on what needs to happen and the whys if you can. Thanks _/_.

        private static async toImg(file: File): Promise<HTMLImageElement> {
        let img = new Image()
        let output = new Promise<HTMLImageElement>((resolve, reject) => {
            img.onload = () => {
                resolve(img)
            }
            img.onerror = (err) => {
                console.log(err)
            }
            let reader = new FileReader()
            reader.onloadend = (e) => {
                let data = reader.result as string
                let blob = new Blob([data], {type: 'image/jpeg'})
                img.src = URL.createObjectURL(blob)
            }
            reader.readAsDataURL(file)
        })
        return output
    }
about 4 years ago · Juan Pablo Isaza
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!