media assets: include image width, height, and file type in EXIF metadata.
Previously the width, height, and file type fields returned by ExifTool weren't saved in the media metadata because they were already saved in the media asset. However, in some cases, it can be useful to compare ExifTool's version of these fields with our own. This can be useful when an image is corrupt and libvips can't get the width or height, or when it's a video and we want to make sure we detected the correct type of video. script/files/123_refresh_media_metatadata.rb needs to be run after this to update the metadata.
This commit is contained in:
@@ -9,8 +9,8 @@ class ExifTool
|
||||
# @see https://exiftool.org/exiftool_pod.html#OPTIONS
|
||||
DEFAULT_OPTIONS = %q(
|
||||
-G1 -duplicates -unknown -struct --binary
|
||||
-x 'System:*' -x ExifToolVersion -x FileType -x FileTypeExtension
|
||||
-x MIMEType -x ImageWidth -x ImageHeight -x ImageSize -x MegaPixels
|
||||
-x 'System:*' -x ExifToolVersion -x FileTypeExtension
|
||||
-x MIMEType -x ImageSize -x MegaPixels
|
||||
).squish
|
||||
|
||||
attr_reader :file
|
||||
|
||||
@@ -273,7 +273,7 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
|
||||
assert_equal(true, @metadata["Flash:Compressed"])
|
||||
assert_not_equal("Install Compress::Zlib to extract compressed information", @metadata["ExifTool:Warning"])
|
||||
assert_equal(6, @metadata.count)
|
||||
assert_equal(9, @metadata.count)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -469,7 +469,7 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
assert_equal(true, @file.is_corrupt?)
|
||||
assert_equal("File format error", @metadata["ExifTool:Error"])
|
||||
assert_equal("89a", @metadata["GIF:GIFVersion"])
|
||||
assert_equal(6, @metadata.count)
|
||||
assert_equal(9, @metadata.count)
|
||||
end
|
||||
|
||||
should "not raise an exception when reading the frame count" do
|
||||
@@ -480,7 +480,7 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
assert_equal(nil, @file.frame_count)
|
||||
assert_equal("File format error", @metadata["ExifTool:Error"])
|
||||
assert_equal("89a", @metadata["GIF:GIFVersion"])
|
||||
assert_equal(6, @metadata.count)
|
||||
assert_equal(9, @metadata.count)
|
||||
assert_nothing_raised { @file.attributes }
|
||||
end
|
||||
end
|
||||
@@ -492,7 +492,7 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
|
||||
assert_equal(true, @file.is_corrupt?)
|
||||
assert_equal("Grayscale", @metadata["PNG:ColorType"])
|
||||
assert_equal(6, @metadata.count)
|
||||
assert_equal(9, @metadata.count)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -503,7 +503,7 @@ class MediaFileTest < ActiveSupport::TestCase
|
||||
|
||||
assert_equal(true, @file.is_corrupt?)
|
||||
assert_equal(1, @metadata["File:ColorComponents"])
|
||||
assert_equal(7, @metadata.count)
|
||||
assert_equal(10, @metadata.count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user