Image Processing with Rails

Originally published at: http://www.sitepoint.com/image-processing-rails/

Images are a crucial part of any application. From a social network to a simple bug tracker, images play an important role. However, managing images is not a trivial task and requires a lot of planning ahead.

In this article allow me to demonstrate how to achieve this in Rails. I’m going to show you how to process your images and create multiple versions in the backend. We’ll also see how to improve the performance of the page by compressing these images without losing quality.

Continue reading this article on SitePoint

Thanks for a good introduction to operate images.
I have a few questions:

  1. I want to know how to save the image files, which is uploaded, with database such as Postgresql.
  2. I want to know how to load the image files from the database and display them on the html page.

If you know how to solve them, could you help me?

Excellent, clear instructional piece. I enjoyed it and learned. Very new to Rails. I’ve hit a wall downloading images to any Article in the Blog app I made and am trying to “customize”. Chose to use Refile and Mini_Magick gem. Followed a very good video presentation. Bottom line is I can store the image, browse for it, select it, it appears selected in the app, and when I “update” it doesn’t upload. A small box half the size of a postage stamp appears where the picture should go. I even selected the test.jpg from your piece, same non-result. I can’t figure out what is missing. Any ideas?

I would recommend storing images on the file system, not in the database. Storing them in the database just bloats your database for no real benefit, whereas if they’re on the file-system, as soon as they appear in an IMG tag, the web-server can serve them directly with no load on your app or database servers.

I recommend looking at the Paperclip gem as it makes handling file uploads really easy.