diff --git a/fastimage.gemspec b/fastimage.gemspec index 3eb0e97..0e7e085 100644 --- a/fastimage.gemspec +++ b/fastimage.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.rubygems_version = %q{1.3.6} s.summary = %q{FastImage - Image info fast} - s.add_development_dependency 'fakeweb', '~> 1.3' + s.add_development_dependency 'fakeweb-fi', '~> 1.3' # Note rake 11 drops support for ruby 1.9.2 s.add_development_dependency('rake', '~> 10.5') s.add_development_dependency('rdoc') diff --git a/lib/fastimage.rb b/lib/fastimage.rb index a17c69d..c00f965 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -483,7 +483,12 @@ class FastImage when 0x89.chr + "P" :png when "II", "MM" - :tiff + case @stream.peek(11)[8..10] + when "APC", "CR\002" + nil # do not recognise CRW or CR2 as tiff + else + :tiff + end when '8B' :psd when "\0\0" diff --git a/test/fixtures/a.CR2 b/test/fixtures/a.CR2 new file mode 100644 index 0000000..220b074 Binary files /dev/null and b/test/fixtures/a.CR2 differ diff --git a/test/fixtures/a.CRW b/test/fixtures/a.CRW new file mode 100644 index 0000000..95953c0 Binary files /dev/null and b/test/fixtures/a.CRW differ diff --git a/test/test.rb b/test/test.rb index 30a5f2d..51efd28 100644 --- a/test/test.rb +++ b/test/test.rb @@ -41,7 +41,9 @@ GoodFixtures = { BadFixtures = [ "faulty.jpg", "test_rgb.ct", - "test.xml" + "test.xml", + "a.CR2", + "a.CRW" ] # 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 @@ -409,4 +411,13 @@ class FastImageTest < Test::Unit::TestCase def test_should_return_content_length_for_data_uri_images assert_equal DataUriImageContentLength, FastImage.new(DataUriImage).content_length end + + def test_canon_raw_formats_are_not_recognised_as_tiff + assert_raises(FastImage::UnknownImageType) do + FastImage.size(TestUrl + "a.CR2", :raise_on_failure=>true) + end + assert_raises(FastImage::UnknownImageType) do + FastImage.size(TestUrl + "a.CRW", :raise_on_failure=>true) + end + end end