The Fast & the Furious Users

Your next webapp better be fast and intuitive. Why? Because your users have no patience and will blame all their frustrations on “bad UX.”

For example, imagine an app where users submit links to hi-res images. What if the app:

  1. can only process JPGs & PNGs?
  2. requires images be least 600 pixels wide?
  3. accepts up to 10 URLs at a time?

That sounds pretty reasonable — but it could take ages to download, process, and report errors for every image. In the meantime, users will get bored and you'll never make it to the top of Product Hunt.

That’s why you need the FastImage Ruby gem from Stephen Sykes. Since most image formats store their metadata at the beginning, FastImage can extract size & format info without downloading the entire file.

For example, here’s a little routine our app could use:

```ruby require ‘fastimage’

def checkImg(x) puts “\nchecking: “+x

# size() returns [width, height] if FastImage.size(x)[0] >= 600 puts “size check - PASS” else puts “size check - FAIL” end

if [“jpeg”, “png”].include? FastImage.type(x).to_s puts “format check - PASS” else puts “format check - FAIL” end end

too small, wrong format, and just right

checkImg(“http://placehold.it/599x300.png/09f/fff”) checkImg(“http://placehold.it/650x200.gif/e4r/fff”) checkImg(“http://placehold.it/625x400.png/e4f/fff”)

output

checking: http://placehold.it/599x300.png/09f/fff

#size check - FAIL #format check - PASS

checking: http://placehold.it/650x200.gif/e4r/fff

#size check - PASS #format check - FAIL

checking: http://placehold.it/625x400.png/e4f/fff

#size check - PASS #format check - PASS ``` You can check the benchmarks in the readme, but trust me — it’s fast. And bonus: there are ports for Python, Go, and Swift.

Do you event comment bruh?
2017 Neal Shyam