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.
10 lines
323 B
Ruby
10 lines
323 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MediaFile::Flash < MediaFile
|
|
# XXX Some Flash files have fractional dimensions; round up to nearest integer.
|
|
# XXX Some Flash files have negative dimensions; clamp to positive numbers.
|
|
def dimensions
|
|
[metadata.width.ceil.clamp(1..), metadata.height.ceil.clamp(1..)]
|
|
end
|
|
end
|