Fix #5065: .webp images upload support
Add ability to upload .webp images. Animated WebP images aren't supported. This is because they aren't supported by FFmpeg yet[1], so generating thumbnails and samples for them would be more complicated than for other formats. [1]: https://trac.ffmpeg.org/ticket/4907
This commit is contained in:
@@ -48,7 +48,7 @@ class ExifTool
|
||||
end
|
||||
|
||||
def is_animated?
|
||||
frame_count.to_i > 1 || is_animated_avif?
|
||||
frame_count.to_i > 1 || is_animated_webp? || is_animated_avif?
|
||||
end
|
||||
|
||||
def is_animated_gif?
|
||||
@@ -59,6 +59,10 @@ class ExifTool
|
||||
file_ext == :png && is_animated?
|
||||
end
|
||||
|
||||
def is_animated_webp?
|
||||
file_ext == :webp && metadata["RIFF:Duration"].present?
|
||||
end
|
||||
|
||||
def is_animated_avif?
|
||||
file_ext == :avif && metadata["QuickTime:CompatibleBrands"].to_a.include?("avis")
|
||||
end
|
||||
@@ -123,8 +127,10 @@ class ExifTool
|
||||
def loop_count
|
||||
return Float::INFINITY if metadata["GIF:AnimationIterations"] == "Infinite"
|
||||
return Float::INFINITY if metadata["PNG:AnimationPlays"] == "inf"
|
||||
return Float::INFINITY if metadata["RIFF:AnimationLoopCount"] == "inf"
|
||||
return metadata["GIF:AnimationIterations"] if has_key?("GIF:AnimationIterations")
|
||||
return metadata["PNG:AnimationPlays"] if has_key?("PNG:AnimationPlays")
|
||||
return metadata["RIFF:AnimationLoopCount"] if has_key?("RIFF:AnimationLoopCount")
|
||||
|
||||
# If the AnimationIterations tag isn't present, then it's counted as a loop count of 0.
|
||||
return 0 if is_animated_gif? && !has_key?("GIF:AnimationIterations")
|
||||
@@ -153,6 +159,8 @@ class ExifTool
|
||||
:avif
|
||||
elsif has_key?("QuickTime:MovieHeaderVersion")
|
||||
:mp4
|
||||
elsif keys.grep(/\ARIFF:/).any?
|
||||
:webp
|
||||
elsif has_key?("Matroska:DocType")
|
||||
:webm
|
||||
elsif has_key?("Flash:FlashVersion")
|
||||
|
||||
Reference in New Issue
Block a user