我想从一个pdf生成多个图像。
我的逻辑是:
has_attached_file :single_magazin,
:styles => {:for_magazine => ["768x1200>", :jpg], :preview => ["725x1200>", :jpg], :thumb => ["100x140>", :jpg] },
:processors => [:ghostscript, :thumbnail],
:convert_options => { :all => '-colorspace RGB -flatten -density 300 -quality 100' },
:path => ":rails_root/public/system/:class/:attachment/:id_partition/:style/:filename"
validates_attachment_content_type :single_magazin,
:content_type => [ 'application/pdf' ],
:error => "only pdf files are allowed"我想上传多个页面的单个PDF,我想输出多个JPG的。每个页面到一个JPG。
我使用的是Rails4。
我安装了ghostscript和ImageMagick。
请帮帮我。
马库斯
发布于 2014-02-13 22:49:38
你可能不需要使用ImageMagick,而是直接使用GS,我不认为ImageMagick暴露了足够多的GS接口来做到这一点。
在Ghostscript中设置-sOutputFile=filename%d.extent,它将为输入的每一页编写一个输出文件。
https://stackoverflow.com/questions/21755946
复制相似问题