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:
@@ -16,6 +16,8 @@ class MediaFile::Image < MediaFile
|
||||
when :avif
|
||||
# XXX Mirrored AVIFs should be unsupported too, but we currently can't detect the mirrored flag using exiftool or ffprobe.
|
||||
!metadata.is_rotated? && !metadata.is_cropped? && !metadata.is_grid_image? && !metadata.is_animated_avif?
|
||||
when :webp
|
||||
!is_animated?
|
||||
else
|
||||
true
|
||||
end
|
||||
@@ -34,11 +36,12 @@ class MediaFile::Image < MediaFile
|
||||
end
|
||||
|
||||
def frame_count
|
||||
if file_ext == :gif
|
||||
image.get("n-pages")
|
||||
elsif file_ext == :png
|
||||
case file_ext
|
||||
when :gif, :webp
|
||||
image.get("n-pages") if image.get_fields.include?("n-pages")
|
||||
when :png
|
||||
metadata.fetch("PNG:AnimationFrames", 1)
|
||||
elsif file_ext == :avif
|
||||
when :avif
|
||||
video.frame_count
|
||||
else
|
||||
nil
|
||||
@@ -124,6 +127,10 @@ class MediaFile::Image < MediaFile
|
||||
file_ext == :png && is_animated?
|
||||
end
|
||||
|
||||
def is_animated_webp?
|
||||
file_ext == :webp && is_animated?
|
||||
end
|
||||
|
||||
def is_animated_avif?
|
||||
file_ext == :avif && is_animated?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user