mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user