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.

Thanks @Colin.

Yes, I think that the path was an issue.

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

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

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.

On 8 September 2010 20:13, Abder-Rahman A. [email protected]
wrote:

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

Colin L. wrote:

On 8 September 2010 21:50, Abder-Rahman A. [email protected]
wrote:

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:

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

Provided that I’m using:

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

In “show.html.erb”.

How can I overcome this path issue?

On 8 September 2010 21:50, Abder-Rahman A. [email protected]
wrote:

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

On 8 September 2010 22:19, Abder-Rahman A. [email protected]
wrote:

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

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

Provided that I’m using:

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

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

On Sep 8, 10:19 pm, Abder-Rahman A. [email protected] wrote:

Colin L. wrote:

src="/images/./public/images/dcm_files/05115014-mr-siemens-avanto-syngo-wit h-palette-icone.jpg"
/>

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.

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.

Thanks @radhames.

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

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

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

Thanks.

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

http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm

Where I remove the path and keep the file name.

radhames brito wrote:

great good luck

Thanks @radhames :slight_smile:

great good luck

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

Scott R. wrote in post #1030990:

On Nov 8, 2011, at 9:56 PM, Rajashekar R. wrote:

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”.

On Nov 8, 2011, at 9:56 PM, Rajashekar R. wrote:

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.

Rajashekar R. wrote in post #1031004:

Scott R. wrote in post #1030990:

On Nov 8, 2011, at 9:56 PM, Rajashekar R. wrote:

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.

On 9 November 2011 04:56, Rajashekar R. [email protected] wrote:

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

Did you try google for help? Searching for rails dicom and gem dicom
gave lots of hits that look interesting. I imagine few if any here
know about dicom.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs