FIX: Use ImageMagick to detect animated images (#11702)

This is a fallback when FastImage cannot be used (animated WEBP images).
This commit is contained in:
Bianca Nenciu
2021-01-13 19:01:30 +02:00
committed by GitHub
parent 26337408a9
commit 74b95c88ac
3 changed files with 47 additions and 4 deletions

View File

@ -137,6 +137,9 @@ RSpec.describe UploadCreator do
let(:animated_filename) { "animated.gif" }
let(:animated_file) { file_from_fixtures(animated_filename) }
let(:animated_webp_filename) { "animated.webp" }
let(:animated_webp_file) { file_from_fixtures(animated_webp_filename) }
before do
SiteSetting.png_to_jpg_quality = 1
end
@ -208,6 +211,20 @@ RSpec.describe UploadCreator do
expect(File.extname(upload.url)).to eq('.gif')
expect(upload.original_filename).to eq('animated.gif')
end
it 'should not convert animated WEBP images' do
expect do
UploadCreator.new(animated_webp_file, animated_webp_filename,
force_optimize: true
).create_for(user.id)
end.to change { Upload.count }.by(1)
upload = Upload.last
expect(upload.extension).to eq('webp')
expect(File.extname(upload.url)).to eq('.webp')
expect(upload.original_filename).to eq('animated.webp')
end
end
end