Ruby can't see RMagick installed from gem on FC4

L

Lance Squire

unknown said:
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.... :)

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)
 
L

Lance Squire

unknown said:
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 <controller not set>#<action not set>

Could not find RubyGem RMagick (> 0.0.0)
-----

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

lance
 
L

Lance Squire

unknown said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top