我使用Rails 3和回形針。我的邏輯允許用戶上傳圖像。這可以正常工作,除非用戶選擇不是圖像的文件。回形針 - 圖像上傳錯誤:「不能被'識別'命令識別。」
如果用戶選擇一個文本文件,例如,驗證通行證但與此錯誤結束:
5 errors prohibited the profile update:
Profile pic content type is not one of image/jpeg, image/png, image/gif
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
至少第一誤差指的是該文件類型。但是,如果用戶上傳一些更具體的文件,像.PXM
,然後Rails的行爲怪異,並顯示此:
4 errors prohibited the profile update:
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
有誰知道這是怎麼回事?我有下面的代碼在我的模型:
validates_attachment_content_type :profile_pic, :content_type=>['image/jpeg', 'image/png', 'image/gif']
...這回形針初始化:
Paperclip.options[:command_path] = "/opt/local/bin/"
ImageMagik似乎已安裝並正確設置:
$ which Magick-config
/opt/local/bin/Magick-config
謝謝!
什麼'which identify',''locate_id''或'find/-name identify'返回? – Eric 2010-11-20 02:16:57
$確定 /opt/local/bin/identify – AnApprentice 2010-11-20 02:25:39
我用可卡因0.3.2修正了這個問題。請參閱http://stackoverflow.com/questions/12753157/paperclipnotidentifiedbyimagemagickerror-in-spreeadminimagescontrollercre/12771707#12771707 – 2012-10-07 18:50:05