Can't read image

hi all,

i wanna generate thumbnail from image

i found RMagick and found this code but i can’t run it, so please anyone
help me in this issue.

my code

def index
img = Magick::Image.read (’/images/img2.jpg’).first
width, height = 100, 100
thumb = img.resize(width, height)
thumb.write(’/images/mythumbnail.jpg’)
end

but it throws this exception

unable to open image `/images/img2.jpg’: No such file or directory

thanks

On Oct 17, 2007, at 11:26 AM, Mohamed S. wrote:

def index

thanks

Posted via http://www.ruby-forum.com/.

You probably need to File.expand_path(‘public’ + ‘/images/img2.jpg’,
RAILS_ROOT)

to get a real file name on your system. I presume that the ‘/images/
img2.jpg’ will be replaced with some variable that is meant to be an
absolute “web” path, but you need a “file system” path.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]