次のスクリプトを使って vim で <img>タグを挿入する際に width, height 属性を自動入力する。 画像の情報を取得するのに ImageMagick の identify を使用している。 スクリプトファイルは適当な名前(imgsize)で PATH の通った場所に保存する。 #!/usr/bin/env ruby ARGV.each { |file| if FileTest.file?(file) then info_str = `identify #{file}` if info_str.length > 0 then info_array = info_str.sub(/(\s\d+)x(\d+\s)/) {$1 + " " + $2}.split(/\s/) puts '<img src="' + File.basename(info_array[0]) + '"

