From c329d323fc2cc9ba1c486932556afd8fbd9333cc Mon Sep 17 00:00:00 2001 From: Luciano Sousa Date: Sun, 30 Dec 2018 18:14:49 -0500 Subject: Permit generating variants of TIFF images --- activestorage/CHANGELOG.md | 4 ++++ activestorage/lib/active_storage/engine.rb | 2 ++ activestorage/test/fixtures/files/racecar.tif | Bin 0 -> 33705838 bytes activestorage/test/models/variant_test.rb | 11 +++++++++++ 4 files changed, 17 insertions(+) create mode 100644 activestorage/test/fixtures/files/racecar.tif (limited to 'activestorage') diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index b643895893..cece15ff06 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,3 +1,7 @@ +* Permit generating variants of TIFF images. + + *Luciano Sousa* + * Use base36 (all lowercase) for all new Blob keys to prevent collisions and undefined behavior with case-insensitive filesystems and database indices. diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb index b3bcf48d6f..e2e9b70b69 100644 --- a/activestorage/lib/active_storage/engine.rb +++ b/activestorage/lib/active_storage/engine.rb @@ -27,6 +27,7 @@ module ActiveStorage image/jpg image/jpeg image/pjpeg + image/tiff image/vnd.adobe.photoshop image/vnd.microsoft.icon ) @@ -49,6 +50,7 @@ module ActiveStorage image/gif image/jpg image/jpeg + image/tiff image/vnd.adobe.photoshop image/vnd.microsoft.icon application/pdf diff --git a/activestorage/test/fixtures/files/racecar.tif b/activestorage/test/fixtures/files/racecar.tif new file mode 100644 index 0000000000..0a11b22896 Binary files /dev/null and b/activestorage/test/fixtures/files/racecar.tif differ diff --git a/activestorage/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb index 012aee3cc9..d98935eb9f 100644 --- a/activestorage/test/models/variant_test.rb +++ b/activestorage/test/models/variant_test.rb @@ -133,6 +133,17 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase assert_equal 20, image.height end + test "resized variation of TIFF blob" do + blob = create_file_blob(filename: "racecar.tif") + variant = blob.variant(resize: "50x50").processed + assert_match(/racecar\.png/, variant.service_url) + + image = read_image(variant) + assert_equal "PNG", image.type + assert_equal 50, image.width + assert_equal 33, image.height + end + test "optimized variation of GIF blob" do blob = create_file_blob(filename: "image.gif", content_type: "image/gif") -- cgit v1.2.3