Image resize issue in firefox using javascript -


i trying resize image using following code

this image uploader tags

<input type="file" name="files" id="imgupload" onchange="readurlbottom(this)" value="select" > <ul id="logoplaceholder"></ul> 

and following javascript code using image resize

var objbottom, reader, imgdata, maxheight, maxwidth, imageheight, imagewidth;   function readurlbottom(input)  {     if (input.files && input.files[0])      {         reader = new filereader();         reader.onload = function (e)          {             objbottom = new image();             objbottom.src = e.target.result;              imageheight  = objbottom.height;             imagewidth  = objbottom.width;              if (imagewidth > maxwidth)              {                 imageheight = imageheight / (imagewidth / maxwidth);                 imagewidth = maxwidth;             }              var c = document.createelement('canvas');              c.height = imageheight;             c.width = imagewidth;              var ctx = c.getcontext("2d");             ctx.drawimage(objbottom, 0, 0, imagewidth, imageheight);              objbottom.src = c.todataurl();              var strtoappend = '<li class="span3"><a  class="thumbnail"><i onclick=removeimage(this) class="icon-remove pull-right"></i><img src="' + objbottom.src + '" width="100px"/></a></li><p></p>';             $("#logoplaceholder").html(strtoappend);          };          reader.readasdataurl(input.files[0]);     } } 

this works fine in chrome. not works on firefox. getting 0 following 2 values in firefox.

imageheight  = objbottom.height; imagewidth  = objbottom.width; 

try using code onload of image object.

objbottom = new image(); objbottom.onload = function(){     //your code } objbottom.src = //set source here 

also check console errors.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -