我幾天來一直對此感到震驚。最近,我的圖片上傳器已停止正常工作。我已經研究了幾種可能性,但是沒有任何建議的解決方案適用於我的情況。PaperClip錯誤縮放圖像時出現NotIdentifiedByImageMagickError
的錯誤信息是:
#<Paperclip::Errors::NotIdentifiedByImageMagickError:Paperclip::Errors::NotIdentifiedByImageMagickError>
下面是詳細信息:
- 的Mac OS X 10.8.3
- 的ImageMagick 6.8.4-4 2013年3月29日
- libtool =>/usr/bin/libtool
- Rails 3.2.13
- Ruby 1.9.3p19 4
development.rb
包含適當的路徑(和我已驗證它使用which identify
是正確的)
Paperclip.options[:command_path] = "/usr/local/bin/"
Gemfile.lock
(相關部分)
paperclip (3.4.1)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
MODEL(我更新教室對象,但圖片駐留在位置模型中。 (Classroom has_one :location, :as => :locatable)
型號location.rb
class Location < ActiveRecord::Base
## Paperclip method for uploading location images
has_attached_file :picture, :styles => {:show => "1200x500#", :medium => "300x300#", :thumb => "100x100>"}, :convert_options => {:show => "-gravity center"}
has_attached_file :building_sign, :styles => { :show => ["1200x500#", :jpg], :medium => ["300x300#", :jpg], :thumb => ["100x100#", :jpg] }, :convert_options => {:show => "-gravity center"}
belongs_to :locatable, :polymorphic => true
belongs_to :location_type
validates :name, :presence => true
validates :latitude, :presence => true,
:length => {:within => 9..18},
:numericality => true
validates :longitude, :presence => true,
:length => {:within => 9..18},
:numericality => true
end
控制器classrooms_controller.rb
def update
@classroom = Classroom.find_by_facility_code_heprod(params[:id].upcase)
respond_to do |format|
if @classroom.update_attributes(params[:classroom])
format.html { redirect_to(@classroom, :notice => 'Classroom was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @classroom.errors, :status => :unprocessable_entity }
end
end
end
我已經試過。
- 我確定圖像名稱很簡單(USB2230.jpg),沒有冒號。
- 我已經將ImageMagick的版本更新爲最新版本。
- 我也重新下載並重新安裝了10.8.3的CommandLine工具(有人提出這個問題可能與過時的libtool有關)。
- 我重新啓動了電腦。
我試過在創業板的版本變化,包括
# variation 1 gem 'paperclip', '~> 2.8.0' gem "cocaine", "=0.3.2" # variation 2 gem "paperclip", "~> 3.4.0" gem "cocaine", "= 0.4" # variation 3 (which is what is reflected in the included Gemfile.lock info above). gem "paperclip", "~> 3.4.0"
如果我刪除縮放,
:styles => {:show => "1200x500#", :medium => "300x300#", :thumb => "100x100>"},
:convert_options => {:show => "-gravity center"}
上傳的作品,但我種需要縮放;-)
任何人都可以看到我失蹤的東西嗎?
該版本已經在3.4.1和可卡因在0.5.0(如上面列出的Gemfile.lock所示)。 – humbledaisy