title: node.js canvas Image as a 'background'
body: <p>it possible to 'fillpattern in images'  using node.js npm canvas ?</p>
  
  <p>I tried following way.but i got the error</p>
  
  <p>return new CanvasPattern(image);
           ^
  Error: Image given has not completed loading.</p>
  
  <pre><code>   exports.convertImg = function(story){
  
          var Canvas = require('canvas')
          , canvas = new Canvas(200,200)
          , ctx = canvas.getContext('2d'),textDimensions, img = new Canvas.Image;
  
            var textWidth = ctx.measureText(story).width;
  
            img.src = "/images/fillimage.png";
            var buffer = new Buffer(story, "base64"),length=buffer.length;
  
            var pat=ctx.createPattern(img,"repeat");
            ctx.fillStyle = pat;
  
            ctx.font = "20px verdana";
  
            var x= (canvas.width -200) / 2;
            var y= 60;
            wrapText(ctx,story,x,y,200,200);
  
            var imges =  canvas.toDataURL();
            var data = imges.replace(/^data:image\/\w+;base64,/, "");
            var buf = new Buffer(data, 'base64');
  
            var length=buf.length;
            return  images;
          }
  </code></pre>
  
  <p>how can i fill background images in canvas fillpattern. plz help me.</p>
  
  <p>Thanks.</p>