]> git.openstreetmap.org Git - rails.git/commitdiff
Use image_processing macros to resize images
authorTom Hughes <tom@compton.nu>
Tue, 11 May 2021 19:28:20 +0000 (20:28 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 12 May 2021 17:49:21 +0000 (18:49 +0100)
Gemfile
Gemfile.lock
app/helpers/user_helper.rb
app/mailers/user_mailer.rb

diff --git a/Gemfile b/Gemfile
index 2802fe3ad9e192da777684ca18ffe5856b1a3383..fd1df513cc0dfd448a4e0bca3710b881020d2bc7 100644 (file)
--- 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
index fb3ac9cb928ea6fefafb8f7de278a0fcde0a78f9..af52b2d01e8df92b08a1ca73db127e1d9dc7f846 100644 (file)
@@ -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)
index e9e8f6bfb1e553b0066250c2bcdaa1069d23c2bf..69b0f6d6bc5ca833e9df2983b60596fee60f95d2 100644 (file)
@@ -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
index 0664b8475ed866cc6244ac664ae76a45aa49cb60..ae176c321e6cfcbee787a2c7759a89e3c32e6711 100644 (file)
@@ -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