実際、このトピックに関する知識が不足しているため、この疑問をどのように尋ねるか完全に混乱しています.
私が必要としているのは、画像ファイル(png
)を作成したいということです。そのためには、ubuntuで実行可能ファイルを実行します(ファイルはimagemagick and works successfully in
node.js)
と同じように機能し、テキストを書き込み、pngを場所に出力します/local/bin/img.png
次のプロセス。ここでイメージ ツールを実行します。 sampleexe
writeme = IO.popen("~/local/bin/sampleexe", "w")
以下のコードを使用して画像ファイルに書き込み、1 つの場所に保存します。しかし、次のコードが正しいかどうかはわかりません。
writeme = IO.popen("~/local/bin/sampleexe", "w")
writeme.puts "hello" # program will get hello\n on STDIN
writeme.puts "font=Chewy"
writeme.puts "font_size=40"
writeme.puts "message=Hello,world"
writeme.puts <<-HTML
<h2>ffffffffffffffffffffffffff</h2>
width=900
HTML
writeme.puts 'output=./local/bin/img.png'
writeme.close
上記のパスにファイルを取得img.png
しましたが、開くことができませんでした。助けてください。
node.jsを使用すると、ツールsampleexe
は入力(テキストメッセージ、テキストボックス)を正常に書き込み、これらの入力をpngファイルに出力します。ルビーも使用して同じように実装する必要があります
node.js
作業コード
var spawn = require('child_process').spawn;
var imgGen = spawn('sampleexe');
imgGen.stderr.on('data', function(chunk) {
console.error(chunk.toString());
});
imgGen.stdin.write('width=900\n');
imgGen.stdin.write('height=400\n');
imgGen.stdin.write('textboxes=<textboxes>'
+ '<textbox><rect>0,0,500,250</rect><color>0,0,0</color><font>Helvetica</font><align>Center</align><message>' + url.query.msg1 + '</message></textbox>'
+ '<textbox><rect>0,250,300,100</rect><color>200,0,0</color><font>Helvetica</font><align>Right</align><message>' + url.query.msg2 + '</message></textbox>'
+ '<textbox><rect>600,50,200,300</rect><color>255,153,10</color><font>Helvetica</font><justify>true</justify><message>'+url.query.msg3 + '</message></textbox>'
+ '</textboxes>\n');
imgGen.stdin.write('output=/tmp/img.png\n');