aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
diff options
context:
space:
mode:
authorLuciano Sousa <ls@lucianosousa.net>2018-12-30 18:14:49 -0500
committerGeorge Claghorn <george.claghorn@gmail.com>2018-12-30 18:14:49 -0500
commitc329d323fc2cc9ba1c486932556afd8fbd9333cc (patch)
tree02bb3e552fc4e75792dc0611d0b34be88238261e /activestorage
parente7bcbf7b29107d93633746644b1e18e626366934 (diff)
downloadrails-c329d323fc2cc9ba1c486932556afd8fbd9333cc.tar.gz
rails-c329d323fc2cc9ba1c486932556afd8fbd9333cc.tar.bz2
rails-c329d323fc2cc9ba1c486932556afd8fbd9333cc.zip
Permit generating variants of TIFF images
Diffstat (limited to 'activestorage')
-rw-r--r--activestorage/CHANGELOG.md4
-rw-r--r--activestorage/lib/active_storage/engine.rb2
-rw-r--r--activestorage/test/fixtures/files/racecar.tifbin0 -> 33705838 bytes
-rw-r--r--activestorage/test/models/variant_test.rb11
4 files changed, 17 insertions, 0 deletions
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
--- /dev/null
+++ b/activestorage/test/fixtures/files/racecar.tif
Binary files 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")