Ruby can't see RMagick installed from gem on FC4

unknown wrote:

in short

  • you’ve got RMagick installed correctly

  • you’ve posted two errors caused by typos

    1. RMagick vs Magick

    2. require ‘rmagick’ vs. require ‘RMagick’

the example i posted showed how to do both correctly.

O.K… :slight_smile:

Still no Love…

This change:

def make_thumb(location, image, thumb)
  require 'rubygems'
  require_gem 'RMagick'
  include Magick

  pic = Magick::Image.read(location + image)

Produces this error:

Could not find RubyGem RMagick (> 0.0.0)

On Sat, 5 Aug 2006, Lance S. wrote:

Trying to use Rmagick to make thumbnails of images previously stored on
the drive.

You’ve seen the errors above. here is the code as it stands now:

all your erros showed the constant ‘RMagick’ - that doesn’t exist. it’s
Magick, as you’ve got below. somewhere in your code you’ve got the
constant
RMagick if you’re actually getting the error shown.

def make_thumb(location, image, thumb)
require ‘rubygems’
require_gem ‘rmagick’

this is ‘RMagick’ not ‘rmagick’

 white_bg = Magick::Image.new(64, thumb.height)
 pic = white_bg.composite(thumb, Magick::CenterGravity,

Magick::OverCompositeOp)
pic.write("#{location}#{thumb}")
end

in short

  • you’ve got RMagick installed correctly

  • you’ve posted two errors caused by typos

    1. RMagick vs Magick

    2. require ‘rmagick’ vs. require ‘RMagick’

the example i posted showed how to do both correctly.

for this you should be able to find your error. rest assured though,
you have
correctly installed RMagick.

good luck.

-a

On Sat, 5 Aug 2006, Lance S. wrote:

Guess I’ll be moving this to a ‘Rails can’t see RMagick’ thread…

that’s not the issue. rails is ruby. if ruby sees it rails sees it.
what
might not see it is you web user’s account, or some other variant.

try this from you rails root

./script/console

require ‘RMagick’

p Magick

i’ll bet it works

-a

unknown wrote:

rest assured though,
you have
correctly installed RMagick.

good luck.

-a

Thanks,

Guess I’ll be moving this to a ‘Rails can’t see RMagick’ thread…

unknown wrote:

try this from you rails root

./script/console

require ‘RMagick’

p Magick

i’ll bet it works

-a

Might help if I know what constitutes ‘works’ is :wink:

Here’s the output:

$ script/console
Loading development environment.

require ‘RMagick’
=> true

p Magick
Magick
=> nil

On Sat, 5 Aug 2006, Lance S. wrote:

i’ll bet it works
=> true

p Magick
Magick
=> nil

so, there you have it - ruby, rmagick, and rails altogether. any errors
you
have now are, unfortunately, purely bugs in your own code ;-(

in this one

http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/8b1dd2eef7f7c0ef/63605438ec4258a2?hl=en#63605438ec4258a2

it’s

require ‘rubygems’
require ‘RMagick’

not just

require ‘RMagick’

in this one

http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/8b1dd2eef7f7c0ef/63605438ec4258a2?hl=en#63605438ec4258a2

it’s

Magick

not

RMagick

in this one

http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/8b1dd2eef7f7c0ef/63605438ec4258a2?hl=en#63605438ec4258a2

you are running the requires and includes at instance, not class level

etc.

you’ve got everything installed correctly and rails sees it too. now
you’ve
just got to work out the bugs.

regards.

-a

unknown wrote:

you’ve got everything installed correctly and rails sees it too. now
you’ve
just got to work out the bugs.

regards.

-a

Thanks for the debugging/verifying so far.
(Just got back to the project)

I have tried moveing the:

require ‘rubygems’
require_gem ‘RMagick’

above and just below the “class” line in the controller. In either case
I get:

Gem::LoadError in #

Could not find RubyGem RMagick (> 0.0.0)

Contrary to the previous tests this is telling me that it cant find
RMagick…

lance

unknown wrote:

you are running the requires and includes at instance, not class level

etc.

After Much more Googleing for working code samples.

I notice that they All had the “require ‘RMagick’” under the ‘def’ line.

This put me back to the error:


undefined method `columns’ for #Array:0xb791c810

I have long forgotten why I removed the ‘.first’ from the:

pic = Magick::Image.read(location + image).first

line, so I replaced it.

NOW things started giving me errors I could understand!!!

As the latest sample was far more eloquent than the original I was
trying to use, I substuted it for some of the code that wasn’t working,
beacuse I missed something from the original code.

This is the result:

def make_thumb(location, image, thumb)
#require ‘rubygems’
#require_gem ‘RMagick’
#include Magick
require ‘RMagick’

pic = Magick::Image.read(location + image).first
#imgwidth = pic.columns
#imgheight = pic.rows
#imgratio = imgwidth.to_f / imgheight.to_f
#imgratio > aspectratio ? scaleratio = 64 / imgwidth : scaleratio = 

64 / imgheight
#thumb = pic.resize(scaleratio)
pic.change_geometry!(‘64x64’) { |cols, rows, img|
pic.resize!(cols, rows)}

white_bg = Magick::Image.new(64, 64)
pic = white_bg.composite(pic, Magick::CenterGravity, 

Magick::OverCompositeOp)
pic.write(location + thumb)
end

or more cleaned-up as:

def make_thumb(location, image, thumb)
require ‘RMagick’

pic = Magick::Image.read(location + image).first
pic.change_geometry!('64x64') { |cols, rows, img|
                                  pic.resize!(cols, rows)}

white_bg = Magick::Image.new(64, 64)
pic = white_bg.composite(pic, Magick::CenterGravity, 

Magick::OverCompositeOp)
pic.write(location + thumb)
end

This code works flawlessly!

Unfortunatly, My original attempts to fix the original error were,
misguided and caused more errors than could probably be debugged
remotly.

Much thanks for conferming that RMagick was installed and working
properly.

Lance F. Squire