title: Uncaught TypeError: Cannot read property 'width' of null
body: <p>I'm trying out fabric.js, and right now I'm trying to put in an image to experiment with.</p>
  
  <p>I've followed <a href="http://fabricjs.com/fabric-intro-part-1/#images" rel="nofollow">the tutorial</a> but even so I get the following error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'width' of null
  </code></pre>
  
  <p>... which refers to line 14805 in all.js:</p>
  
  <pre><code>_setWidthHeight: function(options) {
      this.width = 'width' in options
          ? options.width
          : (this.getElement().width || 0);    // &lt;------ this line
      this.height = 'height' in options
          ? options.height
          : (this.getElement().height || 0);
  },
  </code></pre>
  
  <p><strong>My code (html):</strong></p>
  
  <pre><code>...
  &lt;div id="avatarBox"&gt;
      &lt;canvas id="canvas" width="500" height="500"/&gt;
      &lt;img src="img/test.png" id="my-image"&gt;
  &lt;/div&gt;
  ...
  </code></pre>
  
  <p><strong>My code (js):</strong></p>
  
  <pre><code>var canvas = new fabric.Canvas('canvas');
  var imgElement = document.getElementById('my-img');
  
  var imgInstance = new fabric.Image(imgElement, {
      left: 100,
      top: 100,
      angle: 30,
      opacity: 0.85
  });
  
  canvas.add(imgInstance);
  </code></pre>
  
  <p>What can be wrong?</p>