How do I load a psd file so it renders on a page like an image in Ruby on Rails? I have no problem loading my image files. For example, this works fine
%img{alt: 'icons', src: image_path('icons/others/users.svg') }
Users
but this does not
%img{ alt: 'Colours', src: image_path('/colours.psd')}
2
Answers
You’ll need to export the .psd file to a supported image file, such as a .jpeg, .png, .gif, etc.
This has nothing to do with rails. When the tag is rendered, it is a normal img tag in the browser. I don’t think any browser would support *.psd files, since this is a proprietary format. Check this list: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#Supported_image_formats
In theory you could make some additions to the rails asset pipeline and add some converter to the asset precompilation process, that converts your psd files to regular web formats, but I don’t think something like that exists already.
Just convert your *.psd file to a web format with photoshop or some other program that can handle this format and you are good to go.