This repository has been archived by the owner on Jul 25, 2019. It is now read-only.
forked from maciejkowalski/devmeeting-proxy-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.old.js~
72 lines (49 loc) · 1.44 KB
/
image.old.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
var im = require('imagemagick'),
fs = require("fs");
function convertImage(scrImage) {
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', srcImage ],
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();
safeRead("/home/dev/node-cb/image.js", function(error, file) { console.log(file)} );
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(12121);
console.log("Server has started.");
function safeRead(filename, callback) {
fs.readFile(filename, "utf-8", function (err, data) {
if (err) {
if (error.errno === process.ENOENT) {
// Ignore file not found errors and return an empty result
callback(null, "");
} else {
// Pass other errors through as is
callback(err);
}
} else {
// Pass successes through as it too.
callback(null, data);
}
});
}