aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2017-12-08 13:15:04 -0500
committerGeorge Claghorn <george@basecamp.com>2017-12-08 13:15:04 -0500
commitda8e0ba03cbae33857954c0c1a228bd6dae562da (patch)
tree624c4efb44e7b18ea4e5b1b04bca81d025026bac /activestorage/lib
parent131cc6eab64eeae6c7f508dca4176183144cf3a6 (diff)
downloadrails-da8e0ba03cbae33857954c0c1a228bd6dae562da.tar.gz
rails-da8e0ba03cbae33857954c0c1a228bd6dae562da.tar.bz2
rails-da8e0ba03cbae33857954c0c1a228bd6dae562da.zip
Swap raw video width and height if angle is 90 or 270 degrees
Diffstat (limited to 'activestorage/lib')
-rw-r--r--activestorage/lib/active_storage/analyzer/video_analyzer.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activestorage/lib/active_storage/analyzer/video_analyzer.rb b/activestorage/lib/active_storage/analyzer/video_analyzer.rb
index b6fc54d917..1c144baa37 100644
--- a/activestorage/lib/active_storage/analyzer/video_analyzer.rb
+++ b/activestorage/lib/active_storage/analyzer/video_analyzer.rb
@@ -31,10 +31,18 @@ module ActiveStorage
private
def width
- Integer(video_stream["width"]) if video_stream["width"]
+ rotated? ? raw_height : raw_width
end
def height
+ rotated? ? raw_width : raw_height
+ end
+
+ def raw_width
+ Integer(video_stream["width"]) if video_stream["width"]
+ end
+
+ def raw_height
Integer(video_stream["height"]) if video_stream["height"]
end
@@ -52,6 +60,10 @@ module ActiveStorage
end
end
+ def rotated?
+ angle == 90 || angle == 270
+ end
+
def tags
@tags ||= video_stream["tags"] || {}