3
votes

I configured my rails app to use Carrierwave for image uploads. As per the docs, I included the appropriate gem version for Multiple File Uploads. Inside the Carrierwave uploader, I included Minimagick. When I try to use the #resize_to_fill method, I get the following error, and the upload fails:

ActiveRecord::RecordInvalid: Validation failed: Images translation missing: en.errors.messages.mini_magick_processing_error

However, when I switch from Minimagick to Rmagick, it works perfectly? I'd prefer to use Minimagick if possible. Another wierd thing is other methods like #resize_to_fit work perfectly with both Minimagick and Rmagick. Has anyone had this problem???

Here are the important files:

Gemfile

gem 'rails',                   '5.0.1'
gem 'bcrypt',                  '3.1.11'
gem 'faker',                   '1.6.6'
gem 'carrierwave',              github: 'carrierwaveuploader/carrierwave'
gem 'mini_magick',             '4.5.1'
# gem 'rmagick',              '~> 2.15', '>= 2.15.4'
gem 'fog',                     '1.38.0'
gem 'will_paginate',           '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap',            '~> 4.0.0.alpha6'

source 'https://rails-assets.org' do
  gem 'rails-assets-tether', '>= 1.3.3'
end

gem 'puma',                    '3.4.0'
gem 'pg',   '0.18.4'
gem 'sass-rails',              '5.0.6'
gem 'uglifier',                '3.0.0'
gem 'coffee-rails',            '4.2.1'
gem 'jquery-rails',            '4.1.1'
gem 'turbolinks',              '5.0.1'
gem 'jbuilder',                '2.4.1'

group :development, :test do
  gem 'byebug',  '9.0.0', platform: :mri
end

group :development do
  gem 'web-console',           '3.1.1'
  gem 'listen',                '3.0.8'
  gem 'spring',                '1.7.2'
  gem 'spring-watcher-listen', '2.0.0'
end

group :test do
  gem 'rails-controller-testing', '0.1.1'
  gem 'minitest-reporters',       '1.1.9'
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end

uploaders/images_uploader.rb

class ImagesUploader < CarrierWave::Uploader::Base
  # Include RMagick or MiniMagick support:

  # include CarrierWave::RMagick (only this one works)
  include CarrierWave::MiniMagick

  process resize_to_fill: [900, 600]

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

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

  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

Both Minimagick and Rmagick should support #resize_to_fill according to the docs as well as many examples that I've seen online. I also tried using different versions of Carrierwave and Minimagick but nothing worked. I also tried reinstalling Imagemagick. Still nothing.

Can someone please help! Also, if I cannot get Minimagick to work, is Rmagick really that bad to use? People are really against it from what I've seen. Thanks!

2

2 Answers

0
votes

Maybe it's too late. But I already faced with this issue. To solve it, you should:

  1. Make sure you already install ImageMagick before you use Mini_magick
  2. Restart your machine.

Then it's worked.

-1
votes

Might also verify that you are using a direct link to an image if you are adding an image by remote url, for example, a shortened URL from cloud app may not work.