-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimage.js~
74 lines (55 loc) · 1.73 KB
/
image.js~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var im = require('imagemagick'),
fs = require("fs");
function convertImage(scrImage, dstImage) {
fs.readFile(scrImage, "binary", function(error, file) {
if(error) {
response.writeHead(500, {"Content-Type": "text/plain"});
response.write(error + "\n");
response.end();
} else {
response.writeHead(200, {"Content-Type": "image/png"});
response.write(file, "binary");
response.end();
}
});
var path = "./tmp/";
im.convert([ srcImage , '-resize', '120x120', dstImage ],
function(err, metadata){
if (err) throw err
console.log('stdout:', stdout);
});
}
var http = require("http");
//var func = require("./func");
function onRequest(request, response){
console.log("Testing image");
testStat();
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(12121);
console.log("Server has started.");
function testStat() {
fs.stat("/home/dev/node-cb/costam", function (status, stats) {
console.log("stats: " + JSON.stringify(stats));
console.log("\n\n "+stats);
});
fs.readFile("/home/dev/node-cb/costam", "binary", function(error, file) {
if(error) {
console.log('response.writeHead(500, {"Content-Type": "text/plain"});');
console.log('response.write(error + "\n");');
console.log('response.end();');
} else {
console.log('response.writeHead(200, {"Content-Type": "image/png"});');
console.log('response.write(file, "binary");');
console.log('response.end();');
console.log(error);
console.log(file);
}
});
fs.readFile('/etc/passwd', function (err, data) {
if (err) throw err;
console.log(data);
});
}