-2

I tried to set up for uploading photos with my rails app. However, the carrierwave uploader does not resize the photos being uploaded. When I do not call the resize_to_fill function, the photos are uploaded perfectly. Any advice?

When a photo is submitted with resize_to_fill, the error 'failed to be processed' is returned. How can i fix it?

I guess I need to 'require' 'carrierwave/processing/mini_magick' for calling resize_to_fill, but i don't know where to put this file.

gemfile
"carrierwave", "0.4.10"
"mini_magick", "3.2.1"
"rails", "2.3.14"

Platform
win7 64bit
ruby 1.8.7 imagemagick (path = C:\ImageMagick-6.7.2-Q16)

batterhead


thanks for your reply. Below is my coding, please advise.
i'm just thinking does the problem come from my combination of win7 + imagemagick + mini_magick + carrierwave? such a problem should have been reproduced easily by many people, i guess. are those versions incompatible with each other?

i just tested my application and tried to upload a photo again. a processing_error returned:
Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: Command ("identify -ping C:/Users/User/mini_magick20111018-4296-f18lsi-0.jpg") failed: {:output=>"'identify' \244\243\254O\244\272\263\241\251Υ~\263\241\251R\245O\241B............", :status_code=>1}
of course the jpg was not created in C:/Users/User folder. please help.

{avatar_uploader.rb}  
class AvatarUploader < CarrierWave::Uploader::Base  
  include CarrierWave::MiniMagick  
  storage :file  
  def store_dir  
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"  
  end

  process :resize_to_fill => [320, 240]

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

{event_photo.rb}  
class EventPhoto < ActiveRecord::Base  
  attr_accessible :event_id, :avatar, :created_by, :updated_by  

  belongs_to:event
  mount_uploader :avatar, AvatarUploader  
end

{preinitializer.rb}  
begin  
  require 'rubygems'  
  require 'bundler'  
end
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
user661684
  • 221
  • 1
  • 4
  • 9

2 Answers2

2

I've run into a similar issue, though not on Windows, though this information may help.

From the Github page on MiniMagick (https://github.com/probablycorey/mini_magick/), it seems that MiniMagik relies on the "mogrify" command.

The first step in my debugging the issue was to ensure that the correct libraries were built on my dev, staging and production systems and that the "mogrify" command was available.

To get there, on my OS/X system, I had to uninstall and reinstall ImageMagik, which I did with macports.

I verified the installation with "identify filename" and then did the following in Rails console:

filename = '/Users/me/tmp/testfile.jpg'
image = MiniMagick::Image.open(filename)
Peter Degen-Portnoy
  • 786
  • 1
  • 8
  • 16
  • We just installed ImageMagick in production, verified using the same code snippet above and all is working as expected. Good luck! – Peter Degen-Portnoy Dec 12 '11 at 20:22
  • This snippet and lots of debugging led me to a fork of subexec which is required to get MiniMagick working on JRuby with Windows. The fork is: https://github.com/rdp/subexec and the Gemfile line which fixed it for me was: gem "subexec", :git => "https://github.com/rdp/subexec.git" – Alexander Kellett Nov 11 '14 at 11:07
0

Step 1: Check if mini_magick is working properly

  • You must have ImageMagick or GraphicsMagick installed.

Step 2. Try following command on your irb

> irb
> require 'mini_magick'
> filename = '/Users/me/tmp/testfile.jpg'
> image = MiniMagick::Image.open(filename)
  • If you are getting errors while running this program like "no decode delegate for this image format" go to Step 3.

Step 3: Check Imagemagick supported formats

> identify -list format
  • The list must have jpg listed. If not go to Step 4.

Step 4. Download and install decode delegates for Imagemagick

Site: http://www.imagemagick.org/download/delegates/

> tar -zxvf jpegsrc.v8b.tar.gz
> cd jpegsrc.v8b
> sudo ./configure
> sudo make
> sudo make install
  • After that re-install the Imagemagick
crazycrv
  • 2,395
  • 2
  • 19
  • 20