diff -Nru ruby-fastimage-1.6.3/debian/changelog ruby-fastimage-1.6.8/debian/changelog --- ruby-fastimage-1.6.3/debian/changelog 2014-11-03 07:01:54.000000000 +0000 +++ ruby-fastimage-1.6.8/debian/changelog 2015-03-16 15:12:46.000000000 +0000 @@ -1,6 +1,12 @@ +ruby-fastimage (1.6.8-1) unstable; urgency=medium + + * Imported Upstream version 1.6.8 + + -- Youhei SASAKI Tue, 17 Mar 2015 00:12:42 +0900 + ruby-fastimage (1.6.3-1) unstable; urgency=medium * Team upload. * Initial release (Closes: #759421) - -- Youhei SASAKI Mon, 03 Nov 2014 16:01:34 +0900 + -- Youhei SASAKI Wed, 27 Aug 2014 15:01:51 +0900 diff -Nru ruby-fastimage-1.6.3/debian/patches/0002-Drop-some-tests-which-need-network-connectivity.patch ruby-fastimage-1.6.8/debian/patches/0002-Drop-some-tests-which-need-network-connectivity.patch --- ruby-fastimage-1.6.3/debian/patches/0002-Drop-some-tests-which-need-network-connectivity.patch 2014-11-03 07:01:54.000000000 +0000 +++ ruby-fastimage-1.6.8/debian/patches/0002-Drop-some-tests-which-need-network-connectivity.patch 2015-03-16 15:12:25.000000000 +0000 @@ -7,11 +7,9 @@ test/test.rb | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) -diff --git a/test/test.rb b/test/test.rb -index 1a429b3..771d2ce 100644 --- a/test/test.rb +++ b/test/test.rb -@@ -34,12 +34,9 @@ TestUrl = "http://example.nowhere/" +@@ -43,12 +43,9 @@ # this image fetch allows me to really test that fastimage is truly fast # but it's not ideal relying on external resources and connectivity speed @@ -27,7 +25,7 @@ GoodFixtures.each do |fn, info| FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn)) -@@ -203,19 +200,6 @@ class FastImageTest < Test::Unit::TestCase +@@ -218,19 +215,6 @@ FakeWeb.register_uri(:get, from, :response=>resp) end @@ -47,7 +45,7 @@ # This test doesn't actually test the proxy function, but at least # it excercises the code. You could put anything in the http_proxy and it would still pass. # Any ideas on how to actually test this? -@@ -228,11 +212,6 @@ class FastImageTest < Test::Unit::TestCase +@@ -250,10 +234,10 @@ assert_equal actual_size, size end @@ -55,7 +53,10 @@ - size = FastImage.size(HTTPSImage) - assert_equal HTTPSImageInfo[1], size - end -- ++ # def test_should_handle_https_image ++ # size = FastImage.size(HTTPSImage) ++ # assert_equal HTTPSImageInfo[1], size ++ # end + require 'pathname' def test_should_handle_pathname - # bad.jpg does not have the size info in the first 256 bytes diff -Nru ruby-fastimage-1.6.3/fastimage.gemspec ruby-fastimage-1.6.8/fastimage.gemspec --- ruby-fastimage-1.6.3/fastimage.gemspec 2014-06-12 07:50:02.000000000 +0000 +++ ruby-fastimage-1.6.8/fastimage.gemspec 2015-03-05 19:27:06.000000000 +0000 @@ -1,10 +1,10 @@ Gem::Specification.new do |s| s.name = %q{fastimage} - s.version = "1.6.3" + s.version = "1.6.8" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Stephen Sykes"] - s.date = %q{2014-06-12} + s.date = %q{2015-03-05} s.description = %q{FastImage finds the size or type of an image given its uri by fetching as little as needed.} s.email = %q{sdsykes@gmail.com} s.extra_rdoc_files = [ @@ -17,8 +17,8 @@ "lib/fastimage/fbr.rb", "test/fixtures/faulty.jpg", "test/fixtures/test.bmp", + "test/fixtures/test2.bmp", "test/fixtures/test.gif", - "test/fixtures/test.ico", "test/fixtures/test.jpg", "test/fixtures/test.png", "test/fixtures/test2.jpg", @@ -32,7 +32,14 @@ "test/fixtures/folder with spaces/test.bmp", "test/test.rb", "test/fixtures/test.psd", - "test/fixtures/bad.jpg" + "test/fixtures/bad.jpg", + "test/fixtures/man.ico", + "test/fixtures/test.cur", + "test/fixtures/gzipped.jpg", + "test/fixtures/truncated_gzipped.jpg", + "test/fixtures/webp_vp8.webp", + "test/fixtures/webp_vp8l.webp", + "test/fixtures/webp_vp8x.webp" ] s.homepage = %q{http://github.com/sdsykes/fastimage} s.rdoc_options = ["--charset=UTF-8"] @@ -41,8 +48,9 @@ s.summary = %q{FastImage - Image info fast} s.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.5' s.add_development_dependency 'fakeweb', '~> 1.3' - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency('rake') + s.add_development_dependency('rdoc') + s.add_development_dependency('test-unit') s.test_files = [ "test/test.rb" diff -Nru ruby-fastimage-1.6.3/Gemfile.lock ruby-fastimage-1.6.8/Gemfile.lock --- ruby-fastimage-1.6.3/Gemfile.lock 2014-06-12 07:50:02.000000000 +0000 +++ ruby-fastimage-1.6.8/Gemfile.lock 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -PATH - remote: . - specs: - fastimage (1.6.2) - addressable (~> 2.3, >= 2.3.5) - -GEM - remote: https://rubygems.org/ - specs: - addressable (2.3.6) - fakeweb (1.3.0) - json (1.8.1) - rake (10.3.1) - rdoc (4.1.1) - json (~> 1.4) - -PLATFORMS - ruby - -DEPENDENCIES - fakeweb (~> 1.3) - fastimage! - rake - rdoc diff -Nru ruby-fastimage-1.6.3/.gitignore ruby-fastimage-1.6.8/.gitignore --- ruby-fastimage-1.6.3/.gitignore 2014-06-12 07:50:02.000000000 +0000 +++ ruby-fastimage-1.6.8/.gitignore 2015-03-05 19:27:06.000000000 +0000 @@ -1 +1,2 @@ pkg/ +Gemfile.lock diff -Nru ruby-fastimage-1.6.3/lib/fastimage/fbr.rb ruby-fastimage-1.6.8/lib/fastimage/fbr.rb --- ruby-fastimage-1.6.3/lib/fastimage/fbr.rb 2014-06-12 07:50:02.000000000 +0000 +++ ruby-fastimage-1.6.8/lib/fastimage/fbr.rb 2015-03-05 19:27:06.000000000 +0000 @@ -64,4 +64,3 @@ end end end - diff -Nru ruby-fastimage-1.6.3/lib/fastimage.rb ruby-fastimage-1.6.8/lib/fastimage.rb --- ruby-fastimage-1.6.3/lib/fastimage.rb 2014-06-12 07:50:02.000000000 +0000 +++ ruby-fastimage-1.6.8/lib/fastimage.rb 2015-03-05 19:27:06.000000000 +0000 @@ -8,10 +8,10 @@ # No external libraries such as ImageMagick are used here, this is a very lightweight solution to # finding image information. # -# FastImage knows about GIF, JPEG, BMP, TIFF, PNG and PSD files. +# FastImage knows about GIF, JPEG, BMP, TIFF, ICO, CUR, PNG, PSD and WEBP files. # # FastImage can also read files from the local filesystem by supplying the path instead of a uri. -# In this case FastImage uses the Addressable library to read the file in chunks of 256 bytes until +# In this case FastImage reads the file in chunks of 256 bytes until # it has enough. This is possibly a useful bandwidth-saving feature if the file is on a network # attached disk rather than truly local. # @@ -36,7 +36,7 @@ # * http://snippets.dzone.com/posts/show/805 # * http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/ # * http://pennysmalls.wordpress.com/2008/08/19/find-jpeg-dimensions-fast-in-pure-ruby-no-ima/ -# * http://imagesize.rubyforge.org/ +# * https://rubygems.org/gems/imagesize # * https://github.com/remvee/exifr # @@ -45,6 +45,7 @@ require 'fastimage/fbr.rb' require 'delegate' require 'pathname' +require 'zlib' class FastImage attr_reader :size, :type @@ -53,8 +54,6 @@ class FastImageException < StandardError # :nodoc: end - class MoreCharsNeeded < FastImageException # :nodoc: - end class UnknownImageType < FastImageException # :nodoc: end class ImageFetchFailure < FastImageException # :nodoc: @@ -64,9 +63,9 @@ class CannotParseImage < FastImageException # :nodoc: end - DefaultTimeout = 2 + DefaultTimeout = 2 unless const_defined?(:DefaultTimeout) - LocalFileChunkSize = 256 + LocalFileChunkSize = 256 unless const_defined?(:LocalFileChunkSize) # Returns an array containing the width and height of the image. # It will return nil if the image could not be fetched, or if the image type was not recognised. @@ -77,7 +76,7 @@ # If you wish FastImage to raise if it cannot size the image for any reason, then pass # :raise_on_failure => true in the options. # - # FastImage knows about GIF, JPEG, BMP, TIFF, PNG and PSD files. + # FastImage knows about GIF, JPEG, BMP, TIFF, ICO, CUR, PNG, PSD and WEBP files. # # === Example # @@ -98,6 +97,8 @@ # FastImage.size("http://pennysmalls.com/does_not_exist", :raise_on_failure=>true) # => raises FastImage::ImageFetchFailure # FastImage.size("http://stephensykes.com/favicon.ico", :raise_on_failure=>true) + # => [16, 16] + # FastImage.size("http://stephensykes.com/images/squareBlue.icns", :raise_on_failure=>true) # => raises FastImage::UnknownImageType # FastImage.size("http://stephensykes.com/favicon.ico", :raise_on_failure=>true, :timeout=>0.01) # => raises FastImage::ImageFetchFailure @@ -137,7 +138,7 @@ # => :bmp # FastImage.type("test/fixtures/test.jpg") # => :jpeg - # FastImage.type("http://pennysmalls.com/does_not_exist") + # FastImage.type("http://stephensykes.com/does_not_exist") # => nil # File.open("/some/local/file.gif", "r") {|io| FastImage.type(io)} # => :gif @@ -159,6 +160,7 @@ def initialize(uri, options={}) @property = options[:type_only] ? :type : :size @timeout = options[:timeout] || DefaultTimeout + @proxy_url = options[:proxy] @uri = uri if uri.respond_to?(:read) @@ -167,12 +169,12 @@ begin @parsed_uri = Addressable::URI.parse(uri) rescue Addressable::URI::InvalidURIError - fetch_using_open_uri + fetch_using_file_open else if @parsed_uri.scheme == "http" || @parsed_uri.scheme == "https" fetch_using_http else - fetch_using_open_uri + fetch_using_file_open end end end @@ -235,6 +237,21 @@ end end + case res['content-encoding'] + when 'deflate', 'gzip', 'x-gzip' + begin + gzip = Zlib::GzipReader.new(FiberStream.new(read_fiber)) + rescue FiberError, Zlib::GzipFile::Error + raise CannotParseImage + end + + read_fiber = Fiber.new do + while data = gzip.readline + Fiber.yield data + end + end + end + parse_packets FiberStream.new(read_fiber) break # needed to actively quit out of the fetch @@ -243,7 +260,11 @@ def proxy_uri begin - proxy = ENV['http_proxy'] && ENV['http_proxy'] != "" ? Addressable::URI.parse(ENV['http_proxy']) : nil + if @proxy_url + proxy = Addressable::URI.parse(@proxy_url) + else + proxy = ENV['http_proxy'] && ENV['http_proxy'] != "" ? Addressable::URI.parse(ENV['http_proxy']) : nil + end rescue Addressable::URI::InvalidURIError proxy = nil end @@ -288,8 +309,8 @@ parse_packets FiberStream.new(read_fiber) end - def fetch_using_open_uri - open(@uri) do |s| + def fetch_using_file_open + File.open(@uri) do |s| fetch_using_read(s) end end @@ -377,11 +398,28 @@ :tiff when '8B' :psd + when "\0\0" + # ico has either a 1 (for ico format) or 2 (for cursor) at offset 3 + case @stream.peek(3).bytes.to_a.last + when 1 then :ico + when 2 then :cur + end + when "RI" + if @stream.peek(12)[8..11] == "WEBP" + :webp + else + raise UnknownImageType + end else raise UnknownImageType end end + def parse_size_for_ico + @stream.read(8)[6..7].unpack('CC').map{|byte| byte == 0 ? 256 : byte } + end + alias_method :parse_size_for_cur, :parse_size_for_ico + def parse_size_for_gif @stream.read(11)[6..10].unpack('SS') end @@ -446,6 +484,45 @@ [result.first, result.last.abs] end + def parse_size_for_webp + vp8 = @stream.read(16)[12..15] + len = @stream.read(4).unpack("V") + case vp8 + when "VP8 " + parse_size_vp8 + when "VP8L" + parse_size_vp8l + when "VP8X" + parse_size_vp8x + else + nil + end + end + + def parse_size_vp8 + w, h = @stream.read(10).unpack("@6vv") + [w & 0x3fff, h & 0x3fff] + end + + def parse_size_vp8l + @stream.read(1) # 0x2f + b1, b2, b3, b4 = @stream.read(4).bytes.to_a + [1 + (((b2 & 0x3f) << 8) | b1), 1 + (((b4 & 0xF) << 10) | (b3 << 2) | ((b2 & 0xC0) >> 6))] + end + + def parse_size_vp8x + flags = @stream.read(4).unpack("C")[0] + b1, b2, b3, b4, b5, b6 = @stream.read(6).unpack("CCCCCC") + width, height = 1 + b1 + (b2 << 8) + (b3 << 16), 1 + b4 + (b5 << 8) + (b6 << 16) + + if flags & 8 > 0 # exif + # parse exif for orientation + # TODO: find or create test images for this + end + + return [width, height] + end + class Exif # :nodoc: attr_reader :width, :height def initialize(stream) diff -Nru ruby-fastimage-1.6.3/README.textile ruby-fastimage-1.6.8/README.textile --- ruby-fastimage-1.6.3/README.textile 2014-06-12 07:50:02.000000000 +0000 +++ ruby-fastimage-1.6.8/README.textile 2015-03-05 19:27:06.000000000 +0000 @@ -10,27 +10,32 @@ But the image is not locally stored - it's on another asset server, or in the cloud - at Amazon S3 for example. -You don't want to download the entire image to your app server - it could be many tens of kilobytes, or even megabytes just to get this information. For most common image types (GIF, PNG, BMP), the size of the image is simply stored at the start of the file. For JPEG files it's a little bit more complex, but even so you do not need to fetch much of the image to find the size. +You don't want to download the entire image to your app server - it could be many tens of kilobytes, or even megabytes just to get this information. For most common image types (GIF, PNG, BMP etc.), the size of the image is simply stored at the start of the file. For JPEG files it's a little bit more complex, but even so you do not need to fetch much of the image to find the size. -FastImage does this minimal fetch for image types GIF, JPEG, PNG, TIFF, BMP and PSD. And it doesn't rely on installing external libraries such as RMagick (which relies on ImageMagick or GraphicsMagick) or ImageScience (which relies on FreeImage). +FastImage does this minimal fetch for image types GIF, JPEG, PNG, TIFF, BMP, ICO, CUR, PSD and WEBP. And it doesn't rely on installing external libraries such as RMagick (which relies on ImageMagick or GraphicsMagick) or ImageScience (which relies on FreeImage). You only need supply the uri, and FastImage will do the rest. h2. Features -Fastimage can also read local (and other) files, and uses the Addressable library to do so. +Fastimage can also read local (and other) files - anything that is not parseable as a URI will be +interpreted as a filename, and FastImage will attempt to open it with File#open. -FastImage will automatically read from any object that responds to :read - for +FastImage will also automatically read from any object that responds to :read - for instance an IO object if that is passed instead of a URI. FastImage will follow up to 4 HTTP redirects to get the image. -FastImage will obey the http_proxy setting in your environment to route requests via a proxy. +FastImage will obey the http_proxy setting in your environment to route requests via a proxy. You can also pass a :proxy argument if you want to specify the proxy address in the call. You can add a timeout to the request which will limit the request time by passing :timeout => number_of_seconds. FastImage normally replies will nil if it encounters an error, but you can pass :raise_on_failure => true to get an exception. +h2. Security + +As of v1.6.7 FastImage no longer uses openuri to open files, but directly calls File.open. But take care to sanitise the strings passed to FastImage; it will try to read from whatever is passed. + h2. Examples

@@ -98,7 +103,7 @@
 
 h2. Tests
 
-You'll need to @gem install fakeweb@ to be able to run the tests.
+You'll need to @gem install fakeweb@ and possibly also  @gem install test-unit@ to be able to run the tests.
 
 bc.. $ ruby test.rb 
 Run options: 
@@ -113,9 +118,15 @@
 * "Pennysmalls - Find jpeg dimensions fast in pure Ruby, no image library needed":http://pennysmalls.wordpress.com/2008/08/19/find-jpeg-dimensions-fast-in-pure-ruby-no-ima/
 * "DZone - Determine Image Size":http://snippets.dzone.com/posts/show/805
 * "Antti Kupila - Getting JPG dimensions with AS3 without loading the entire file":http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/
-* "imagesize gem documentation":http://imagesize.rubyforge.org/
+* "imagesize gem":https://rubygems.org/gems/imagesize
 * "EXIF Reader":https://github.com/remvee/exifr
 
+h2. FastImage in other languages
+
+* "Python by bmuller":https://github.com/bmuller/fastimage
+* "Swift by kaishin":https://github.com/kaishin/ImageScout
+* "Go by rubenfonseca":https://github.com/rubenfonseca/fastimage
+
 h2. Licence
 
 MIT, see file "MIT-LICENSE":MIT-LICENSE
@@ -130,3 +141,6 @@
 * @benjaminjackson
 * @muffinista
 * @marcandre
+* @apanzerj
+* @forresty
+
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/favicon.ico and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/favicon.ico differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/gzipped.jpg and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/gzipped.jpg differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/man.ico and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/man.ico differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/test.cur and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/test.cur differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/test.ico and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/test.ico differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/test_rgb.ct and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/test_rgb.ct differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/truncated_gzipped.jpg and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/truncated_gzipped.jpg differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/webp_vp8l.webp and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/webp_vp8l.webp differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/webp_vp8.webp and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/webp_vp8.webp differ
Binary files /tmp/ZgvcxgLsex/ruby-fastimage-1.6.3/test/fixtures/webp_vp8x.webp and /tmp/9xcMe516Wr/ruby-fastimage-1.6.8/test/fixtures/webp_vp8x.webp differ
diff -Nru ruby-fastimage-1.6.3/test/test.rb ruby-fastimage-1.6.8/test/test.rb
--- ruby-fastimage-1.6.3/test/test.rb	2014-06-12 07:50:02.000000000 +0000
+++ ruby-fastimage-1.6.8/test/test.rb	2015-03-05 19:27:06.000000000 +0000
@@ -24,13 +24,22 @@
   "test.psd"=>[:psd, [17, 32]],
   "exif_orientation.jpg"=>[:jpeg, [600, 450]],
   "infinite.jpg"=>[:jpeg, [160,240]],
-  "orient_2.jpg"=>[:jpeg, [230,408]]
+  "orient_2.jpg"=>[:jpeg, [230,408]],
+  "favicon.ico" => [:ico, [16, 16]],
+  "man.ico" => [:ico, [48, 48]],
+  "test.cur" => [:cur, [32, 32]],
+  "webp_vp8x.webp" => [:webp, [386, 395]],
+  "webp_vp8l.webp" => [:webp, [386, 395]],
+  "webp_vp8.webp" => [:webp, [550, 368]]
 }
 
 BadFixtures = [
   "faulty.jpg",
-  "test.ico"
+  "test_rgb.ct"
 ]
+# man.ico courtesy of http://www.iconseeker.com/search-icon/artists-valley-sample/business-man-blue.html
+# test_rgb.ct courtesy of http://fileformats.archiveteam.org/wiki/Scitex_CT
+# test.cur courtesy of http://mimidestino.deviantart.com/art/Clash-Of-Clans-Dragon-Cursor-s-Punteros-489070897
 
 TestUrl = "http://example.nowhere/"
 
@@ -50,6 +59,12 @@
   FakeWeb.register_uri(:get, "#{TestUrl}#{fn}", :body => File.join(FixturePath, fn))
 end
 
+GzipTestImg = "gzipped.jpg"
+FakeWeb.register_uri(:get, "#{TestUrl}#{GzipTestImg}", :body => File.join(FixturePath, GzipTestImg), :content_encoding => "gzip")
+GzipTestImgTruncated = "truncated_gzipped.jpg"
+FakeWeb.register_uri(:get, "#{TestUrl}#{GzipTestImgTruncated}", :body => File.join(FixturePath, GzipTestImgTruncated), :content_encoding => "gzip")
+GzipTestImgSize = [970, 450]
+
 class FastImageTest < Test::Unit::TestCase
   def test_should_report_type_correctly
     GoodFixtures.each do |fn, info|
@@ -74,7 +89,7 @@
   end
 
   def test_should_return_nil_when_image_type_not_known
-    assert_nil FastImage.size(TestUrl + "test.ico")
+    assert_nil FastImage.size(TestUrl + "test_rgb.ct")
   end
 
   def test_should_return_nil_if_timeout_occurs
@@ -101,7 +116,7 @@
 
   def test_should_raise_when_asked_when_image_type_not_known
     assert_raises(FastImage::UnknownImageType) do
-      FastImage.size(TestUrl + "test.ico", :raise_on_failure=>true)
+      FastImage.size(TestUrl + "test_rgb.ct", :raise_on_failure=>true)
     end
   end
 
@@ -157,7 +172,7 @@
   end
 
   def test_should_return_nil_when_image_type_not_known_for_local_file
-    assert_nil FastImage.size(File.join(FixturePath, "test.ico"))
+    assert_nil FastImage.size(File.join(FixturePath, "test_rgb.ct"))
   end
 
   def test_should_raise_when_asked_to_when_size_cannot_be_found_for_local_file
@@ -230,11 +245,18 @@
     assert_equal actual_size, size
   end
 
+  def test_should_fetch_via_proxy_option
+    file = "test.gif"
+    actual_size = GoodFixtures[file][1]
+    size = FastImage.size(TestUrl + file, :proxy => "http://my.proxy.host:8080")
+    assert_equal actual_size, size
+  end
+
   def test_should_handle_https_image
     size = FastImage.size(HTTPSImage)
     assert_equal HTTPSImageInfo[1], size
   end
-  
+
   require 'pathname'
   def test_should_handle_pathname
     # bad.jpg does not have the size info in the first 256 bytes
@@ -243,4 +265,36 @@
     path = Pathname.new(File.join(FixturePath, "bad.jpg"))
     assert_equal([500,500], FastImage.size(path))
   end
+
+  def test_should_report_type_and_size_correctly_for_stringios
+    GoodFixtures.each do |fn, info|
+      string = File.read(File.join(FixturePath, fn))
+      stringio = StringIO.new(string)
+      assert_equal info[0], FastImage.type(stringio)
+      assert_equal info[1], FastImage.size(stringio)
+    end
+  end
+
+  def test_gzipped_file
+    url = "http://example.nowhere/#{GzipTestImg}"
+    assert_equal([970, 450], FastImage.size(url))
+  end
+
+  def test_truncated_gzipped_file
+    url = "http://example.nowhere/#{GzipTestImgTruncated}"
+    assert_raises(FastImage::SizeNotFound) do
+      FastImage.size(url, :raise_on_failure => true)
+    end
+  end
+
+  def test_cant_access_shell
+    url = "|echo>shell_test"
+    %x{rm -f shell_test}
+    FastImage.size(url)
+    assert_raises(Errno::ENOENT) do
+      File.open("shell_test")
+    end
+  ensure
+    %x{rm -f shell_test}
+  end
 end
diff -Nru ruby-fastimage-1.6.3/.travis.yml ruby-fastimage-1.6.8/.travis.yml
--- ruby-fastimage-1.6.3/.travis.yml	2014-06-12 07:50:02.000000000 +0000
+++ ruby-fastimage-1.6.8/.travis.yml	2015-03-05 19:27:06.000000000 +0000
@@ -4,5 +4,6 @@
   - 1.9.2
   - 1.9.3
   - 2.0.0
+  - 2.1.2
 # uncomment this line if your project needs to run something other than `rake`:
 # script: bundle exec rspec spec
\ No newline at end of file