I need to render jpeg images on nodejs serverside. I install canvas npm module with following build instructions: https://github.com/Automattic/node-canvas/wiki/Installation---Windows I have C:\libjpeg-turbo\ as it is mentioned in the manual. If I do:
npm install canvas
then this piece of code doesn't launch onload:
var data = fs.readFileSync("./t.jpg"); var img = new Image();
img.onload = function () {
console.log("onload");
};
img.src = data;
(it works with .png data). If i specify --with-jpeg in my command line, then MSVC complains about missing libjpeg.h. Right after this npm deletes file with msvc project, so I am unable to set paths myself (is it possible to switch off this cleanup?)
So how can I build canvas for windows with jpeg support? Found questions but no answers regarding this topic on the net.
Install MSVC10 and 64bit nodejs. When your build fails, use the following distributives, which you'll find on the net:
unzip gtk+-bundle_2.22.1-20101229_win64.zip to c:/gtk . Use this version, others failed for me
setup libjpeg-turbo-1.4.0-vc64.exe to C:\libjpeg-turbo (32bit libs would fail with no meaningfull message)
{ 'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle 'with_jpeg%': 'true', 'libjpeg_root%':'C:/libjpeg-turbo', 'with_gif%': 'false', 'with_pango%': 'false', 'with_freetype%': 'false' }
and also
['with_jpeg=="true"', {
'defines': [
'HAVE_JPEG'
],
'conditions': [
['OS=="win"', {
'libraries': [
'-l<(libjpeg_root)/lib/jpeg-static.lib','-l<(libjpeg_root)/lib/jpeg.lib'
],
'include_dirs': [
'<(libjpeg_root)/include'
]
}, {
'libraries': [
'-ljpeg'
]
}]
]
}]
then exec following commands in the folder, where .gyp file is located:
node-gyp configure
node-gyp build
IMHO libraries for such modules should be included as a part of npm distributions, its strange to expect WIN32/C++ expertise from nodejs programmer...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With