RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

On the Fly Image Processing in Ruby

I take a look at popular Ruby file upload gems and point out the problems of upfront image processing. Then I proceed to explain on the fly image processing and its advantages.

Comments

At first I was also attracted to Refile’s on-the-fly processing. However, there are multiple downsides with this:

  • It would be great if the client can choose the size, however *you mustn’t expose the routes to the client, otherwise people can easily DoS you by requesting all kinds of image dimensions. That means that only the server can generate URLs, which lowers the flexibility for apps with separate backend and frontend.
  • The “first” image download gives bad user experience, because the processing can take a long time (e.g. image has to first be downloaded from S3, processed, and then sent again over the wire).
  • What is the right way to cache the images? On Refile people were complaining that Amazon CloudFront caches the images only for couple of hours. This is really a problem, considering the previous bullet. Caching with Nginx is also not ideal, because then you have to have large disk space on your server.

However, Refile’s uploading on file select (through the mounted Sinatra app) is awesome, that’s the first time someone made something like this. But I feel the upfront processing is still the right way, just background processing should be more convenient.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in