class FastImage
def self.type(uri, options={})
If set to true causes an exception to be raised if the image type cannot be found for any reason.
[:raise_on_failure]
Overrides the default timeout of 2 seconds. Applies both to reading from and opening the http connection.
[:timeout]
=== Supported options
=> nil
FastImage.type("http://pennysmalls.com/does_not_exist")
=> :jpeg
FastImage.type("test/fixtures/test.jpg")
=> :bmp
FastImage.type("http://www-ece.rice.edu/~wakin/images/lena512.bmp")
=> :jpeg
FastImage.type("http://farm4.static.flickr.com/3023/3047236863_9dce98b836.jpg")
=> :png
FastImage.type("http://stephensykes.com/images/pngimage")
=> :gif
FastImage.type("http://stephensykes.com/images/ss.com_x.gif")
require 'fastimage'
=== Example
:raise_on_failure => true in the options.
If you wish FastImage to raise if it cannot find the type of the image for any reason, then pass
This can be changed by passing a :timeout => number_of_seconds in the options.
By default there is a timeout of 2 seconds for opening and reading from a remote server.
It will return nil if the image could not be fetched, or if the image type was not recognised.
Returns an symbol indicating the image type fetched from a uri.
def self.type(uri, options={}) new(uri, options.merge(:type_only=>true)).type end