# Can't read image

**URL:** <https://www.ruby-forum.com/t/cant-read-image/117512>\
**Category:** Rails\
**Created:** [October 17, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/cant-read-image/117512 "2007-10-17T17:16:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [October 17, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/cant-read-image/117512/1 "2007-10-17T17:16:55Z")

</div>

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

–  
Mohamed S.  
software engineer

---

<div class="post-metadata">

**Author:** ![shafi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@shafi](https://www.ruby-forum.com/u/shafi)\
**Post date:** [October 17, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/cant-read-image/117512/2 "2007-10-17T17:30:58Z")

</div>

Image.read() is relative not to your web root, but to your host  
operating system’s root.

Try something like:

def index  
fname = RAILS\_ROOT + ‘/images/img2.jpg’  
img = Magick::Image.read(fname)  
img = img.first  
…  
end
