From: Tom Hughes Date: Tue, 11 May 2021 19:28:20 +0000 (+0100) Subject: Use image_processing macros to resize images X-Git-Tag: live~2138^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/cd5d54ce4e65629facc964c3d6f870ced244f797 Use image_processing macros to resize images --- diff --git a/Gemfile b/Gemfile index 2802fe3ad..fd1df513c 100644 --- a/Gemfile +++ b/Gemfile @@ -117,7 +117,7 @@ gem "browser" gem "aws-sdk-s3" # Used to resize user images -gem "mini_magick" +gem "image_processing" # Gems useful for development group :development do diff --git a/Gemfile.lock b/Gemfile.lock index fb3ac9cb9..af52b2d01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -237,6 +237,9 @@ GEM image_optim (~> 0.24) rails sprockets + image_processing (1.12.1) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) image_size (2.1.0) in_threads (1.5.4) jbuilder (2.11.2) @@ -416,6 +419,8 @@ GEM rubocop ruby-openid (2.9.2) ruby-progressbar (1.11.0) + ruby-vips (2.1.2) + ffi (~> 1.12) ruby2_keywords (0.0.4) rubyzip (2.3.0) sanitize (5.2.3) @@ -508,6 +513,7 @@ DEPENDENCIES http_accept_language (~> 2.1.1) i18n-js (>= 3.0.0) image_optim_rails + image_processing jbuilder (~> 2.7) jquery-rails json @@ -518,7 +524,6 @@ DEPENDENCIES logstasher marcel maxminddb - mini_magick minitest (~> 5.1) oauth-plugin (>= 0.5.1) omniauth (~> 2.0.2) diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index e9e8f6bfb..69b0f6d6b 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -8,7 +8,7 @@ module UserHelper if user.image_use_gravatar user_gravatar_tag(user, options) elsif user.avatar.attached? - image_tag user_avatar_variant(user, :resize => "100x100>"), options + image_tag user_avatar_variant(user, :resize_to_limit => [100, 100]), options else image_tag "avatar_large.png", options end @@ -21,7 +21,7 @@ module UserHelper if user.image_use_gravatar user_gravatar_tag(user, options) elsif user.avatar.attached? - image_tag user_avatar_variant(user, :resize => "50x50>"), options + image_tag user_avatar_variant(user, :resize_to_limit => [50, 50]), options else image_tag "avatar_small.png", options end @@ -34,7 +34,7 @@ module UserHelper if user.image_use_gravatar user_gravatar_tag(user, options) elsif user.avatar.attached? - image_tag user_avatar_variant(user, :resize => "50x50>"), options + image_tag user_avatar_variant(user, :resize_to_limit => [50, 50]), options else image_tag "avatar_small.png", options end @@ -44,7 +44,7 @@ module UserHelper if user.image_use_gravatar user_gravatar_url(user, options) elsif user.avatar.attached? - polymorphic_url(user_avatar_variant(user, :resize => "100x100>"), :host => Settings.server_url) + polymorphic_url(user_avatar_variant(user, :resize_to_limit => [100, 100]), :host => Settings.server_url) else image_url("avatar_large.png") end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 0664b8475..ae176c321 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -194,7 +194,7 @@ class UserMailer < ApplicationMailer avatar = user&.avatar if avatar&.attached? if avatar.variable? - image = avatar.variant(:resize => "50x50>").processed + image = avatar.variant(:resize_to_limit => [50, 50]).processed image.service.download(image.key) else avatar.blob.download