media assets: fix dimensions of flash files.
Use ExifTool to get the dimensions of Flash files instead of calculating it ourselves. Avoids copying third-party code. Fixes a bug where Flash files with fractional dimensions (e.g. 607.6 x 756.6) had their dimensions rounded down instead of rounded up. Fixes another bug where Flash files could return negative dimensions. This happened for two files: * https://danbooru.donmai.us/media_assets/228662 (-179.2 x -339.2) * https://danbooru.donmai.us/media_assets/228664 (-179.2 x -339.2) Now we round these up to 1x1. This is still wrong, but it's less wrong than before.
This commit is contained in:
@@ -46,7 +46,7 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "determine the correct dimensions for a flash file" do
|
||||
assert_equal([607, 756], MediaFile.open("test/files/compressed.swf").dimensions)
|
||||
assert_equal([608, 757], MediaFile.open("test/files/compressed.swf").dimensions)
|
||||
end
|
||||
|
||||
should "work if called twice" do
|
||||
@@ -55,8 +55,8 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
assert_equal([500, 335], mf.dimensions)
|
||||
|
||||
mf = MediaFile.open("test/files/compressed.swf")
|
||||
assert_equal([607, 756], mf.dimensions)
|
||||
assert_equal([607, 756], mf.dimensions)
|
||||
assert_equal([608, 757], mf.dimensions)
|
||||
assert_equal([608, 757], mf.dimensions)
|
||||
end
|
||||
|
||||
should "work for a video if called twice" do
|
||||
|
||||
Reference in New Issue
Block a user