diff --git a/lib/paperclip/vips_lazy_thumbnail.rb b/lib/paperclip/vips_lazy_thumbnail.rb index 4764b04af8..fea4b86064 100644 --- a/lib/paperclip/vips_lazy_thumbnail.rb +++ b/lib/paperclip/vips_lazy_thumbnail.rb @@ -52,6 +52,7 @@ module Paperclip # implement. If cropping ever becomes necessary for other situations, this will # need to be expanded. crop_width = crop_height = [target_width, target_height].min if @target_geometry&.square? + crop_width = crop_height = "'min(iw,ih)'" if crop_width == 'ih' filter = begin if @crop diff --git a/spec/fixtures/files/avatar-high.gif b/spec/fixtures/files/avatar-high.gif new file mode 100644 index 0000000000..7639f2c507 Binary files /dev/null and b/spec/fixtures/files/avatar-high.gif differ diff --git a/spec/support/examples/models/concerns/account_avatar.rb b/spec/support/examples/models/concerns/account_avatar.rb index 232f51fa3c..c6cc4e75a5 100644 --- a/spec/support/examples/models/concerns/account_avatar.rb +++ b/spec/support/examples/models/concerns/account_avatar.rb @@ -2,13 +2,20 @@ RSpec.shared_examples 'AccountAvatar' do |fabricator| describe 'static avatars', :attachment_processing do - describe 'when GIF' do + describe 'with a square GIF' do it 'creates a png static style' do account = Fabricate(fabricator, avatar: attachment_fixture('avatar.gif')) expect(account.avatar_static_url).to_not eq account.avatar_original_url end end + describe 'with a higher-than-wide GIF' do + it 'creates a png static style' do + account = Fabricate(fabricator, avatar: attachment_fixture('avatar-high.gif')) + expect(account.avatar_static_url).to_not eq account.avatar_original_url + end + end + describe 'when non-GIF' do it 'does not create extra static style' do account = Fabricate(fabricator, avatar: attachment_fixture('attachment.jpg'))