CSS-Tricks / DragAvatar

HTML5 Drag and Drop Avatar Changer with Resizing and Cropping
http://css-tricks.com/examples/DragAvatar/
74 stars 25 forks source link

Get actual image size #3

Open drianautz opened 9 years ago

drianautz commented 9 years ago

Hello, actually how to get the actuall image size as currently is always set the image to 256 x 256 on w x h, event i change the code to >

var file = files[0];
var width = $("#profile-avatar").width();
var height = $("#profile-avatar").height();

resizeImage: function(file, width, height, callback) {

  var fileTracker = new FileReader;
  fileTracker.onload = function() {
    Resample(
      this.result,
      width,
      height,
      callback
    );
  }
  fileTracker.readAsDataURL(file);

  var minValue = Math.min(img.height, img.width);
  var _width = $("#profile-avatar").width();
  var _height = $("#profile-avatar").height();
  width == null && (width = _width );
  height == null && (height =  _height);
  console.log(_width);
  console.log(_height);

its always show me the 256

Thanks

graygilmore commented 9 years ago

The size is being sent through here: https://github.com/CSS-Tricks/DragAvatar/blob/535bb7f265536befa0a11158a1a77b58a3d53421/avatar.js#L73