Why isn't the image showing up

I have created a Rails application based on this tutorial: http://dicom.rubyforge.org/tutorial1.html

I'm trying to view a DICOM image. I was able to convert .dcm to .jpg.

But, when I try to view the .jpg image I get as shown in the "Snapshot" file attached within this message.

Where is the problem?

Thanks.

Attachments: http://www.ruby-forum.com/attachment/5019/DICOM.zip

Please don't send attachments, just describe the problem and post whatever is necessary to explain what you are doing/seeing.

To save others downloading and opening it up, the OP is seeing a broken link instead of the image. Have a look at the html (View, Page Source or similar in browser) and see the url that is being generated for the image. Does it look correct? Try just opening that url in the browser.

Colin

Thanks @Colin.

Yes, I think that the path was an issue.

Now, in "show.html.rb", I have made this change:

<img src="C:\Users\Abder-Rahman\Desktop\Research\dicom\<%= @examination.image %>" />

And, when I "View source", I have the following path for example

<img src="C:\Users\Abder-Rahman\Desktop\Research\dicom\05115014-mr-siemens-avanto-syngo-with-palette-icone.jpg" />

And, when I try this path in a browser I get the image displayed.

But, the issue of vieewing the image(s) through the Rails application still remains.

You cannot show files on the local machine (that is C:) in a web page, the browser will not allow it. Usually images are put in a folder under the public folder of your app. For example if you put them in public/images then the img src should be /images/filename.jpg

Colin

Colin Law wrote:

<img src="C:\Users\Abder-Rahman\Desktop\Research\dicom\05115014-mr-siemens-avanto-syngo-with-palette-icone.jpg" />

And, when I try this path in a browser I get the image displayed.

You cannot show files on the local machine (that is C:) in a web page, the browser will not allow it. Usually images are put in a folder under the public folder of your app. For example if you put them in public/images then the img src should be /images/filename.jpg

Colin

It seems I'm doing something wrong but not aware of it.

In the dicom_info.rb file which is attached, I made a change in the the loop for retrieving dicom files as follows:

Dir["./public/images/dcm_files/*.dcm"].each do |dcm| dicom_files << dcm end

In this case, when I "View source", I get the path as follows:

<img alt="05115014-mr-siemens-avanto-syngo-with-palette-icone" src="/images/./public/images/dcm_files/05115014-mr-siemens-avanto-syngo-with-palette-icone.jpg" />

Provided that I'm using:

<%= image_tag(@examination.image) %>

In "show.html.erb".

How can I overcome this path issue?

Have you looked at the docs for image_tag? If you do you will see that image_tag( "fiename") provides /images/filename in the img src, so expecting the image to be in public/images. Therefore you need @examination.image to contain just dcm_files/longfilename.jpg or to strip the bit off the front before you pass it to image_tag, or of course you could just code up the img tag yourself rather than using image_tag.

Colin

The path in the image tag should be relative to the public folder, ie something like /images/dcm_files/...

Fred

Thanks @Colin.

Yes, this is the point I'm not able to perform:

"strip the bit off the front before you pass it to image_tag'.

How can I remove the path to the file and keep the file name which I will then pass?

Thanks.

he means you should change this

Dir[“./public/images/dcm_ files/*.dcm”].each do |dcm|

dicom_files << dcm end

to this

Dir[“public/images/dcm_ files/*.dcm”].each do |dcm|

dicom_files << dcm

end

putting the / at the beginning means c:/public/images/dcm_file/*.dcm that means the path is absolute.

Thanks @radhames.

When I change it as you mentioned, and then view the source of the page, I get the path as follows:

<img alt="05115014-mr-siemens-avanto-syngo-with-palette-icone" src="/images/public/images/dcm_files/05115014-mr-siemens-avanto-syngo-with-palette-icone.jpg" />

How can I strip the /images part, which I can see it is causing the path to be wrong?

Thanks.

Sorry, I mean to strip; public/images/

As for example when I view the database, I'm getting this entry for the image file;

public/images/dcm_files/05115014-mr-siemens-avanto-syngo-with-palette-icone.jpg

What I'm looking for is to strip public/images/, so, I have the following entry in the database:

05115014-mr-siemens-avanto-syngo-with-palette-icone.jpg

Any ideas on that?

We have to strip the following; public/images/dcm_files/

Right?

Looking forward for your replies.

Thanks.

Tanks a lot everyone, I got it working using File.basename, based on this tutorial:

Where I remove the path and keep the file name.

great good luck

radhames brito wrote:

great good luck

Thanks @radhames :slight_smile:

How can i implement the dicom in ruby on rails. plz send the code

Well, you can start by asking a question that makes sense.

Scott Ribe wrote in post #1030990:

Rajashekar R. wrote in post #1031004:

Scott Ribe wrote in post #1030990:

How can i implement the dicom in ruby on rails. plz send the code

Well, you can start by asking a question that makes sense.

Can some one guide me in implementing "DICOM" functionality using "ROR". The

attachment was not helped me.

Attachments: http://www.ruby-forum.com/attachment/6733/DICOM.rar

I think you need to ask a more specific question. I’d never heard of DICOM before I read this and I’m very new to ROR. But the attachment seemed very helpful to me.