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:
evazion
2022-10-31 17:12:52 -05:00
parent 2f2c73eebb
commit acc511ab7d
3 changed files with 9 additions and 88 deletions

View File

@@ -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