【问题标题】:using imagemagick in ruby to convert pdf to png在 ruby​​ 中使用 imagemagick 将 pdf 转换为 png
【发布时间】:2015-05-21 01:46:00
【问题描述】:

我正在尝试在this stackoverflow 帖子之后将 pdf 转换为图像。

我通过 brew 在 mac osx 上安装了 imagemagick:

$ brew ls --versions imagemagick
imagemagick 6.8.9-5

现在我尝试完全按照他在 stackoverflow 答案中所做的事情:

> require 'RMagick'
> Dir.chdir "/Users/donato/Downloads"
> Dir.pwd
=> "/Users/donato/Downloads" 
> Dir.entries(Dir.pwd).select {|f| f =~ /sample_template.pdf/}
 => ["sample_template.pdf"]
> pdf =  Magick::ImageList.new("sample_template.pdf")
=> []
  scene= 
> pdf.class
=> Magick::ImageList
2.1.2 :017 > pdf.write "sample_template.png"
  ArgumentError: no images in this image list
  from (irb):17:in `write'
  from (irb):17
  from /Users/donato/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'

write 方法的文档是here

我做错了什么?

【问题讨论】:

    标签: ruby imagemagick


    【解决方案1】:

    显然,这需要一个名为 ghostscript 的依赖项。在 Mac OSX 上,我使用了 brew:

    brew install gs
    

    现在可以了。

    【讨论】:

      猜你喜欢
      • 2011-02-21
      • 1970-01-01
      • 2020-05-31
      • 2018-03-16
      • 2016-08-21
      • 1970-01-01
      • 1970-01-01
      • 2012-09-15
      • 2021-12-14
      相关资源
      最近更新 更多