I'm using node canvas to generate PNG images of HTML5 generated canvas (using fabric.js). I installed it using:
$ PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig npm install canvas
When the canvas contains only PNG images, node-canvas renders the output image just fine. However, if the canvas also has JPEG images embedded, it raises an exception and quits:
/Users/sa125/node_modules/fabric/dist/all.js:14238
ctx.drawImage(
^
Error: Image given has not completed loading
at klass.fabric.Image.fabric.util.createClass._render (/Users/sa125/node_modules/fabric/dist/all.js:14238:11)
at klass.fabric.Image.fabric.util.createClass.render (/Users/sa125/node_modules/fabric/dist/all.js:14108:12)
at extend._draw (/Users/sa125/node_modules/fabric/dist/all.js:6001:16)
at extend.renderAll (/Users/sa125/node_modules/fabric/dist/all.js:6147:16)
at extend.insertAt (/Users/sa125/node_modules/fabric/dist/all.js:6052:37)
at fabric.util.object.extend._enlivenObjects (/Users/sa125/node_modules/fabric/dist/all.js:8950:15)
at Array.forEach (native)
at fabric.util.object.extend._enlivenObjects (/Users/sa125/node_modules/fabric/dist/all.js:8949:24)
at onLoaded (/Users/sa125/node_modules/fabric/dist/all.js:2082:11)
at /Users/sa125/node_modules/fabric/dist/all.js:2101:11
This is not a fabric issue, since when running the same canvas generator on Ubuntu linux, all images come out fine (both JPEG and PNG)
So basically this is a dependency issue - any idea what I need to brew install to get this working? I've already installed libjpeg, as well as pango, cairo, pixbuf, etc. However, I had to install node-canvas using the above PKG_CONFIG since anything else would break the installation, possibly due to how homebrew handled some of the linking. thanks.