Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用send_文件显示位图并添加元刷新标记_Javascript_Ruby On Rails_Bitmap - Fatal编程技术网

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)
套件.样式表