Picture Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: `identify

Picture Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: `identify

一直在尝试使用 Carrierwave::MiniMagick 上传照片,安装了两个 gem,但在尝试上传时出现此错误:

Picture Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: identify C:/Users/JOHNO~1/AppData/Local/Temp/mini_magick20160918-2884-cgqjcw.png failed with error: identify: UnableToOpenConfigureFile magic.xml' @ warning/configure.c/GetConfigureOptions/709. identify: UnableToOpenConfigureFiledelegates.xml' @ warning/configure.c/GetConfigureOptions/709. identify: UnableToOpenModuleFile 'C:\ImageMagick-7.0.2-Q16\modules\coders\IM_MOD_RL_PNG_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/680. identify: NoDecodeDelegateForThisImageFormat `PNG' @ error/constitute.c/ReadImage/508.

页面重新加载时,结果页面显示但图像不显示。

这是我的上传者:

class PictureUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick

  storage :file

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  version :thumb do
     process :resize_to_limit => [200, 200]
  end

  def extension_white_list
    %w(jpg jpeg gif png)
  end

end

这是我的模型:

class Article < ActiveRecord::Base
    mount_uploader :picture, PictureUploader
end

这是我的迁移文件:

class CreateArticles < ActiveRecord::Migration
  def change
    create_table :articles do |t|
        t.string :title
        t.text :body
        t.string :picture
      t.timestamps null: false
    end
  end
end

大家有什么想法吗???....谢谢

找到解决方法!!!我将我的 ImageMagick 安装文件夹移动到与我的站点文件夹相同的路径。它现在可以完美地工作......是的!

在我的例子中,我收到此错误是因为我正在解码 base64 编码的图像字符串,并且我没有删除字符串开头的 data:image/png;base64, header。

Base64 编码图像:

data:image/png;base64,iVBORw0...

解码前删除前 22 个字符后,一切正常。