0

I am working on HTML5 application for mobile. I am using a canvas element and file upload element. Whenever user hit this file upload element from mobile. He sees two options.

  1. Choose existing photo
  2. Take new photo

If he choose existing photo, this is fixed well in my canvas but if he clicks new photo, it does not fit into canvas. Width is fine but height of click image shown in canvas in not more than 50px.

I am facing this issue only in iPhone.

HTML

<canvas id="myCanvas" width="270" height="300"></canvas>
<input type="file" id="uploadImage" name="upload" value="Upload" onchange="PreviewImage();" />

Javascript

function PreviewImage() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
oFReader.onload = function (oFREvent) {
    var canvas = document.getElementById('myCanvas');
    ctx = canvas.getContext('2d');
    ctx.clearRect(0, 0, 270, 300);            
    imageUrl = oFREvent.target.result;
    var base_image = new Image();
    base_image.src = imageUrl;
    base_image.onload = function () {
    ctx.drawImage(base_image, 0, 0, 270, 300);
  }
 };
}

I have searched many sites but could not find solution of this issue. Any help?

Attachment

Find this image to see the demo image.

Bilal Ahmed
  • 235
  • 2
  • 6
  • 17
  • You've just copy-pasted on of your old question. http://stackoverflow.com/questions/25788958/html5-image-fit-issue-in-canvas . Not sure it fits Stack Overflow's rules... – GameAlchemist Sep 14 '14 at 14:22
  • Still unable to find its answer. – Bilal Ahmed Sep 15 '14 at 05:43
  • You did not get any answer from your previous code because your question was not clear enough. Copy-pasting the very same question makes no sense. For instance you could build a jsfiddle that shows the issue. – GameAlchemist Sep 15 '14 at 09:17
  • try to make a jsfiddle with your code – Teo Sep 15 '14 at 15:06

0 Answers0