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

140
Views
Javascript resize base64 image

I have a function that send a base64 image to my input, but I want to resize the image before send to input. I need a 250x250 image, but when take shot from mobile the image goes 3096x3096...

There is my code:

function sendPhoto() {
  if (this.files && this.files[0]) {
    var FR = new FileReader();

    FR.addEventListener('load', function (e) {
      var permitted_files = ['image/png', 'image/jpeg', 'image/bmp'];
      var baseImg = e.target.result;
      var parteImg = baseImg.substring(11, 15);

      if (parteImg.includes('jpeg') || parteImg.includes('png') || parteImg.includes('bmp')) {
        document.getElementById('sendedPhoto').src = e.target.result;
        document.getElementById('btnPhoto').style.display = '';
      } else {
        $('body').overhang({
          type: 'error',
          message: 'This is not an image file.',
        });
        document.getElementById('uploadFoto').value = '';
      }
    });

    FR.readAsDataURL(this.files[0]);
  }
}

Any ideas? Thanks!

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

0

You can use HTML5 Canvas to do that Refer : Canvas Image

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!