Javascript 使用send_文件显示位图并添加元刷新标记
我正在使用Javascript 使用send_文件显示位图并添加元刷新标记,javascript,ruby-on-rails,bitmap,Javascript,Ruby On Rails,Bitmap,我正在使用send_file方法显示一个位图,附件设置为inline,如下所示: def index .. create_image_from_html respond_to do |format| format.html do send_file("luna.bmp", type: 'image/bmp', disposition: 'inline') end end end def create_image_from_html kit =
send_file
方法显示一个位图,附件设置为inline,如下所示:
def index
..
create_image_from_html
respond_to do |format|
format.html do
send_file("luna.bmp", type: 'image/bmp', disposition: 'inline')
end
end
end
def create_image_from_html
kit = IMGKit.new(render_to_string, width: 1024, height: 1280)
kit.stylesheets << "#{Rails.root}/public/assets/" + "#{self.class.helpers.asset_digest_path('application.css')}"
kit.to_file('kit.jpg')
bitmap_from_image('kit.jpg')
end
def bitmap_from_image(file)
# Generate the Bitmap
MiniMagick::Tool::Convert.new do |convert|
convert << file # input
convert.merge! ["-monochrome"] # options
convert << "luna.bmp" # output
end
end
def索引
..
从html创建图像
回应待办事项|格式|
format.html做什么
发送文件(“luna.bmp”,键入:“image/bmp”,处置:“inline”)
结束
结束
结束
def从html创建图像
kit=IMGKit.new(渲染到字符串,宽度:1024,高度:1280)
套件.样式表