Szymon
Szymon

Reputation: 252

Show image after changing format in Rails using imagemagic

I want to show images, I've got urls to do that, but I've got one problem - all of them have extensions 'ico' and I want them to be converted to 'png' and then shown in the view. Is there any simple way to do that or I have to format and save them into model and then show?

Upvotes: 0

Views: 54

Answers (1)

Blackcoat77
Blackcoat77

Reputation: 1625

You can do it on the 'fly'. There are couple of gems which can help you.

Please read these articles first, it may help you for good start:

https://www.sitepoint.com/image-processing-rails/

https://www.new-bamboo.co.uk/blog/2010/01/13/dragonfly/

http://www.learnwithdaniel.com/2015/09/dragonfly-rails-models-with-images-and-files/

Dragonfly gem: https://github.com/markevans/dragonfly

The Dragonfly gem generates new versions on the fly, that can be very resource consuming, so think about using server cache solution. ( rack-cache gem )

In case that you are using carrierwave gem:

https://github.com/carrierwaveuploader/carrierwave/wiki/Efficiently-converting-image-formats#changing-the-format

Hope it helps

Upvotes: 1

Related Questions