These go near the end of config/environment.rb:
require 'RMagick'
include Magick
These go in a controller action, say "show_cat":
def show_cat
cat = ImageList.new("Cheetah.jpg")
image = cat.first # first image frame in the image list
img.format = 'JPG' # force conversion to jpeg if needed
I believe that send_data is a "show stopper" in that it does not
render a template once you use it. At least I don't have a
show_cat.rhtml or other type of file for it to render. Note that this
method could use some error checking to make certain that an image is
actually loaded.
I also do this in the same controller, before calling send_data():
I don't think you understand how images work in html.
To display an image, you use the standard <img
src="http://host/controller/action/id" /> html tag. This calls your
controller with the action you want. For instance, I have a
"avatar_img_tag" helper action which generates image tags of the form:
<img src="/avatar/show/1" />
for me.
When this html is processed by a browser, it will make another request
to your rails code to retrieve the image itself.
That controller has an action, "show", which calls send_data. You
cannot really use the image data directly in your view; you must use
send_data to send the image data.
Hi,
I am trying to install RMAgick but just cant seem to get ImageMagick
working. (ubuntu)
Can you perhaps tell me what gems (including version numbers) you have
installed and in which order.
The actuall links to the gems you installed to get RMagick working would be
a blessing.
Sorry for putting this question here, but you guy's probably all got this
working with ease.