# Rmagick .tif image display

**URL:** <https://www.ruby-forum.com/t/rmagick-tif-image-display/129677>\
**Category:** Rails\
**Created:** [February 20, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/rmagick-tif-image-display/129677 "2008-02-20T17:34:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [February 20, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/rmagick-tif-image-display/129677/1 "2008-02-20T17:34:35Z")

</div>

Hi. I’m trying to display a .tif image file on my web page.

The image is on another physical drive on the server and because .tif  
images don’t display very well i decided to use Rmagick…

I would like to load the image from the server; convert it to a .png;  
display it on the web page.

If possible i don’t want to create a physical .png file on the server.

The closest i’ve got is:  
read the file in,  
convert it to .png and write it to the server (which as i mentioned i  
dont want to do),  
and use \<%= image\_tag(“file:///c:/temp/photo3.png”) %\> in the view.

It works, but just seems very clunky. Any ideas welcome…

Cheers.

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [February 20, 2008, 6:09pm UTC](https://www.ruby-forum.com/t/rmagick-tif-image-display/129677/2 "2008-02-20T18:09:29Z")

</div>

On 20 Feb 2008, at 16:33, MagicLava wrote:

> The closest i’ve got is:  
> read the file in,  
> convert it to .png and write it to the server (which as i mentioned i  
> dont want to do),  
> and use \<%= image\_tag(“file:///c:/temp/photo3.png”) %\> in the view.

Assuming that rmagick can give you the binary data for the png file,  
you should be able to just use send\_data

Fred

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [February 20, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/rmagick-tif-image-display/129677/3 "2008-02-20T19:18:36Z")

</div>

Your clunky feeling is correct, your solution is a bit of fragile.  
At first, you should not convert image each time when somebody  
accessing it. In fact you _should_ write it down and then use saved  
copy in your views. RMagick consume memory, lots of it, if abused, so  
don’t abuse it, please.  
Then, this \<%= image\_tag(“file:///c:/temp/photo3.png”) %\> seems kind  
of wrong. Not sure if it ever worked, but, even if it was, I’m pretty  
sure there will be the point it will stop doing so.  
You have to use path, related to web root, not absolute path on your  
local drive.  
And last, but not least - do not use send\_file. Use  
[http://john.guen.in/rdoc/x\_send\_file/](http://john.guen.in/rdoc/x_send_file/)  
instead.
