Search code examples
ruby-on-railslocalcarrierwaveminimagick

How to solve Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: You must have ImageMagick or GraphicsMagick installed


In production my code is working ok, but locally my code was rollbacking when I tried uploading

So I tried forcing the update to accept the uploading with update! which gave me this error message:

ActiveRecord::RecordInvalid in EmployeesController#photo_upload

Validation failed: Photo Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: You must have ImageMagick or GraphicsMagick installed

So based on that I figured out it had something to do with MiniMagick, with some testing in my uploader file I found that if I commented this line:

process resize_to_fill: [100, 100]

the problem goes away. The thing is I needed that line for a rectangular image to be loaded as a square image so there's no need to play with every picture and CSS. So I'm looking for a long term solution

class PhotoUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick

  process resize_to_fill: [100, 100]

  if Rails.env.production?
    storage :fog
  else
    storage :file
  end

  def store_dir
  end

  def extension_whitelist
    %w[jpg jpeg gif png]
  end

end

Edit:

Based en a couple of comments mentioning to install ImageMagick locally, I researched because my deployment is in Heroku so it's a little different, but it turns out Heroku has ImageMagick installed so that's clearly not the problem. To those who want to corroborate please type:

heroku run identify -version

Solution

  • I've had this problem for like 48hrs now. I figured you just need to do exactly what it says, install ImageMagick. I did brew install imagemagick assuming you're on a Mac. My issue was that I was trying to seed image data(as URLs from a app/assets/images/ folder locally and that's when the error was popping up. Hope it helps.