meteorjs で imagemagick を使用できません。私は、変換された画像を提供する残りの API を含む小さな svg->png コンバーターに取り組んでいます。meteor-router を使用して残りの API を実装しました。imagemagick 変換が機能します。しかし、変換結果をhttpレスポンスに書き込めません。ファイバーを使用して非同期性を取り除くことで、これを修正しようとしました。しかし、これはまだ機能しません。基本的に、すべての request.write 呼び出しは、yield 実行後に無視されます。これが私のコードです:
Meteor.Router.add({
'/image/:hash' : function(hash) {
var svg = Images.findOne({'hash' : hash}).svg;
var request = this.request;
var response = this.response;
Fiber(function() {
var fiber = Fiber.current;
response.writeHead(200, {'Content-Type':'image/png'});
var convert = imagemagick.convert(['svg:-', 'png:-']);
convert.on('data', function(data) {
response.write("doesn't work");
//response.write(data);
});
convert.on('end', function() {
response.write("doesn't work");
//response.end();
fiber.run({});
});
convert.stdin.write(svg);
convert.stdin.end();
response.write("works");
Fiber.yield();
response.write("doesn't work");
}).run();
}
});
私はmeteorjsにかなり慣れていません。したがって、ファイバーを完全に間違って使用する可能性があります。または、繊維をまったく使用しないでください。誰か助けてくれませんか?