Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Revert "Switch from mini_magick to Ruby VIPS" (#11553)
Damian Legawiec4affa9f2098c
diff --git a/.circleci/config.yml b/.circleci/config.ymlindex 4da8338f11..183f1e93c9 100644--- a/.circleci/config.yml+++ b/.circleci/config.yml@@ -27,9 +27,6 @@ run_tests: &run_testskeys:- spree-bundle-v10-ruby-2-7-{{ .Branch }}- spree-bundle-v10-ruby-2-7- - run:- name: Install libvips- command: sudo apt-get install libvips- run:name: Ensure Bundle Installcommand: |@@ -56,9 +53,6 @@ run_tests_3_0: &run_tests_3_0keys:- spree-bundle-v10-ruby-3-0-{{ .Branch }}- spree-bundle-v10-ruby-3-0- - run:- name: Install libvips- command: sudo apt-get install libvips- run:name: Ensure Bundle Installcommand: |@@ -85,9 +79,6 @@ jobs:keys:- spree-bundle-v10-ruby-2-7-{{ .Branch }}- spree-bundle-v10-ruby-2-7- - run:- name: Install libvips- command: sudo apt-get install libvips- run:name: Bundle Installcommand: |@@ -106,9 +97,6 @@ jobs:keys:- spree-bundle-v10-ruby-3-0-{{ .Branch }}- spree-bundle-v10-ruby-3-0- - run:- name: Install libvips- command: sudo apt-get install libvips- run:name: Bundle Installcommand: |@@ -209,9 +197,6 @@ jobs:keys:- spree-bundle-v10-ruby-3-0-{{ .Branch }}- spree-bundle-v10-ruby-3-0- - run:- name: Install libvips- command: sudo apt-get install libvips- run:name: Ensure Bundle Installcommand: |diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rbindex 9272c741b0..f2ec0c1ce2 100644--- a/core/app/helpers/spree/base_helper.rb+++ b/core/app/helpers/spree/base_helper.rb@@ -61,11 +61,11 @@ module SpreeDEPRECATIONimage_path ||= if current_store.logo.attached? && current_store.logo.variable?- main_app.url_for(current_store.logo.variant(resize_to_limit: [244, 104]))+ main_app.url_for(current_store.logo.variant(resize: '244x104>'))elsif current_store.logo.attached? && current_store.logo.image?main_app.url_for(current_store.logo)else- 'logo/spree_50.png'+ 'logo/spree_50.png'endpath = spree.respond_to?(:root_path) ? spree.root_path : main_app.root_pathdiff --git a/core/app/models/concerns/spree/image_methods.rb b/core/app/models/concerns/spree/image_methods.rbindex 9d02132c8e..439e0e2f55 100644--- a/core/app/models/concerns/spree/image_methods.rb+++ b/core/app/models/concerns/spree/image_methods.rb@@ -2,21 +2,19 @@ module Spreemodule ImageMethodsextend ActiveSupport::Concern- def generate_url(size:, gravity: 'centre', quality: 80, background: [0, 0, 0])+ def generate_url(size:, gravity: 'center', quality: 80, background: 'show')return if size.blank?-size = size.gsub(/\s+/, '')return unless size.match(/(\d+)x(\d+)/)- width, height = size.split('x').map(&:to_i)-- # FIXME: bring back support for background color-- polymorphic_path(- attachment.variant(resize_and_pad: [width, height, { gravity: gravity }], saver: { quality: quality }),- only_path: true- )+ polymorphic_path(attachment.variant(+ gravity: gravity,+ resize: size,+ extent: size,+ background: background,+ quality: quality.to_i+ ), only_path: true)enddef original_urldiff --git a/core/app/models/spree/asset/support/active_storage.rb b/core/app/models/spree/asset/support/active_storage.rbindex 619a1f7b7d..c67f315d91 100644--- a/core/app/models/spree/asset/support/active_storage.rb+++ b/core/app/models/spree/asset/support/active_storage.rb@@ -8,7 +8,7 @@ module Spreedef url(style)return placeholder(style) unless attachment.attached?- attachment.variant(resize_to_limit: dimensions_for_style(style))+ attachment.variant(resize: dimensions_for_style(style))enddef placeholder(style)@@ -16,8 +16,7 @@ module Spreeenddef dimensions_for_style(style)- dimensions = self.class.styles.with_indifferent_access[style] || self.class.styles.with_indifferent_access[default_style]- dimensions.split('x').map(&:to_i)+ self.class.styles.with_indifferent_access[style] || self.class.styles.with_indifferent_access[default_style]endendenddiff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rbindex c64dcfa566..bb858a2306 100644--- a/core/app/models/spree/cms_section.rb+++ b/core/app/models/spree/cms_section.rb@@ -18,7 +18,7 @@ module Spreedefine_method("img_#{count}_#{size}") do |dimensions = nil|return if !send("image_#{count}").attached? || dimensions.nil?- send("image_#{count}").variant(resize_to_limit: dimensions.split('x').map(&:to_i))+ send("image_#{count}").variant(resize: dimensions)endendenddiff --git a/core/app/models/spree/image.rb b/core/app/models/spree/image.rbindex 158fb0a213..fe47d98598 100644--- a/core/app/models/spree/image.rb+++ b/core/app/models/spree/image.rb@@ -13,7 +13,7 @@ module Spreedef stylesself.class.styles.map do |_, size|- width, height = size.chop.split('x').map(&:to_i)+ width, height = size.chop.split('x'){url: generate_url(size: size),@@ -28,7 +28,7 @@ module Spreesize = self.class.styles[name]return unless size- width, height = size.chop.split('x').map(&:to_i)+ width, height = size.chop.split('x'){url: generate_url(size: size),@@ -40,7 +40,7 @@ module Spreedef style_dimensions(name)size = self.class.styles[name]- width, height = size.chop.split('x').map(&:to_i)+ width, height = size.chop.split('x'){width: width,diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex d587322093..078f1287f7 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -178,7 +178,7 @@ module Spreedef faviconreturn unless favicon_image.attached?- favicon_image.variant(resize_to_limit: [32, 32])+ favicon_image.variant(resize: '32x32')enddef can_be_deleted?diff --git a/core/app/models/spree/taxon_image.rb b/core/app/models/spree/taxon_image.rbindex 60ab005b45..5602966f71 100644--- a/core/app/models/spree/taxon_image.rb+++ b/core/app/models/spree/taxon_image.rb@@ -6,10 +6,10 @@ module Spreedef stylesself.class.styles.map do |_, size|- width, height = size[/(\d+)x(\d+)/].split('x').map(&:to_i)+ width, height = size[/(\d+)x(\d+)/].split('x'){- url: polymorphic_path(attachment.variant(resize_to_limit: [width, height]), only_path: true),+ url: polymorphic_path(attachment.variant(resize: size), only_path: true),width: width,height: height}diff --git a/core/config/initializers/active_storage.rb b/core/config/initializers/active_storage.rbindex 29d15e378d..5776bc935a 100644--- a/core/config/initializers/active_storage.rb+++ b/core/config/initializers/active_storage.rb@@ -1,2 +1,2 @@Rails.application.config.active_storage.content_types_to_serve_as_binary.delete('image/svg+xml')-Rails.application.config.active_storage.variant_processor = :vips+Rails.application.config.active_storage.variant_processor = :mini_magickdiff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rbindex e35cbef8ce..65800ec727 100644--- a/core/lib/spree/core.rb+++ b/core/lib/spree/core.rb@@ -14,7 +14,7 @@ require 'friendly_id'require 'kaminari'require 'monetize'require 'paranoia'-require 'ruby-vips'+require 'mini_magick'require 'ransack'require 'state_machines-activerecord'require 'active_storage_validations'diff --git a/core/spec/models/spree/store_spec.rb b/core/spec/models/spree/store_spec.rbindex 468bedea62..aaa480adc2 100644--- a/core/spec/models/spree/store_spec.rb+++ b/core/spec/models/spree/store_spec.rb@@ -608,7 +608,7 @@ describe Spree::Store, type: :model doit 'returns a resized favicon' doexpect(favicon_variation).to be_present- expect(favicon_variation.transformations.fetch(:resize_to_limit)).to eq([32, 32])+ expect(favicon_variation.transformations.fetch(:resize)).to eq('32x32')endenddiff --git a/core/spree_core.gemspec b/core/spree_core.gemspecindex e0a7029ada..5adeeddb8d 100644--- a/core/spree_core.gemspec+++ b/core/spree_core.gemspec@@ -51,6 +51,7 @@ Gem::Specification.new do |s|s.add_dependency 'state_machines-activemodel', '~> 0.7's.add_dependency 'stringex's.add_dependency 'validates_zipcode'+ s.add_dependency 'mini_magick', '~> 4.9', '>= 4.9.4's.add_dependency 'image_processing', '~> 1.2's.add_dependency 'active_storage_validations', '~> 0.9', '<= 0.9.5's.add_dependency 'activerecord-typedstore'diff --git a/emails/app/helpers/spree/mail_helper.rb b/emails/app/helpers/spree/mail_helper.rbindex 1dae324ca3..9860b2b96c 100644--- a/emails/app/helpers/spree/mail_helper.rb+++ b/emails/app/helpers/spree/mail_helper.rb@@ -26,7 +26,7 @@ module Spreedef logo_pathreturn default_logo unless store_logo.attached?- return main_app.url_for(store_logo.variant(resize_to_limit: [244, 104])) if store_logo.variable?+ return main_app.url_for(store_logo.variant(resize: '244x104>')) if store_logo.variable?return main_app.url_for(store_logo) if store_logo.image?end