Paperclip正在处理图像,但不适用于PDF文件

时间:2012-01-10 20:38:15

标签: ruby-on-rails upload paperclip

我有一个使用Paperclip的Rails 3.1应用程序。它在本地完美运行,但在服务器上我似乎无法让PDF上传工作。 PNG和JPG图像效果很好。

尝试使用PDF附件保存记录时出现以下错误:

Avatar /tmp/stream20120110-10803-1whykjx-0.pdf is not recognized by the 'identify' command.
Avatar /tmp/stream20120110-10803-1whykjx-0.pdf is not recognized by the 'identify' command.

我检查了显示以下内容的Apache日志:

sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-or6g2v-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-or6g2v-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
cache: [POST /courses] invalidate, pass
sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-vgyyz8-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-vgyyz8-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
cache: [POST /courses] invalidate, pass

我无法解决问题所在,Imagemagick安装在服务器上(运行Ubuntu),图像文件完美运行。我看不到文件大小限制的任何引用,所以我认为不是。

感谢任何帮助!

编辑:

只是为了确认我已经查找了'识别'没有识别等问题,并尝试将以下内容添加到我的production.rb环境文件中:

Paperclip.options[:command_path] = "/usr/bin/identify"

但这没有任何区别。

1 个答案:

答案 0 :(得分:1)

对于任何有兴趣的人,我采取了以下步骤来纠正这个问题。请注意,我需要调整图像大小,缩略图等。

我更改了这样的模型代码:

class User < ActiveRecord::Base
  has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

到此:

class User < ActiveRecord::Base
  has_attached_file :avatar
end