title: Get image name from Facebook image url
body: <p>I want to use Facebook profile image as the profile image for my site when the user logins via Facebook. I am using omniauth gem for Facebook login. After login, omniauth gives Facebook response in the form of a Hash which looks like this:</p>
  
  <pre><code>{
    "user_info" =&gt; {
                     "last_name" =&gt; "..........", 
                     "image" =&gt; "http://graph.facebook.com/100002356868026/picture?type=square",
                     "first_name" =&gt; "........", 
                     "email" =&gt; "xxxxx@xxx.xxx"
                    },
    "uid" =&gt; "..........."
  }
  </code></pre>
  
  <p>Here, I can access the image url using <code>request.omniauth["user_info"]["image"]</code> and can save it using</p>
  
  <pre><code>require 'open-uri'
  image_url = request.omniauth["user_info"]["image"]
  image_data = open(image_url).read
  File.open("image.png", "wb") { |file| file &lt;&lt; image_data }
  </code></pre>
  
  <p>I want to get the image name from the url. But, the Facebook url doesnt contain the name (It is a link which redirects to another page whose url contains the image name). How can I parse the image name from the url?</p>