diff --git a/Gemfile.lock b/Gemfile.lock index ab8c9283..334e353c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,7 +5,7 @@ PATH RedCloth (~> 4.3.2) bcrypt (~> 3.1.11) chronic (~> 0.10.2) - dragonfly (>= 1.2, < 1.5) + dragonfly (~> 1.4.0) duktape (~> 2.0.1.1) execjs (~> 2.9.1) httparty (~> 0.21.0) diff --git a/lib/locomotive/steam/initializers/dragonfly.rb b/lib/locomotive/steam/initializers/dragonfly.rb index 49141089..f0516da1 100644 --- a/lib/locomotive/steam/initializers/dragonfly.rb +++ b/lib/locomotive/steam/initializers/dragonfly.rb @@ -1,3 +1,5 @@ +require 'dragonfly' + module Locomotive module Steam module Initializers @@ -5,8 +7,6 @@ module Initializers class Dragonfly def run - require 'dragonfly' - # need to be called outside of the configure method imagemagick_commands = find_imagemagick_commands @@ -15,6 +15,10 @@ def run plugin :imagemagick, imagemagick_commands end + processor :convert do |content, args| + ::Dragonfly::ImageMagick::Commands.convert(content, args) + end + verify_urls true secret Locomotive::Steam.configuration.image_resizer_secret diff --git a/lib/locomotive/steam/services/image_resizer_service.rb b/lib/locomotive/steam/services/image_resizer_service.rb index 9a24dcd2..d9905190 100644 --- a/lib/locomotive/steam/services/image_resizer_service.rb +++ b/lib/locomotive/steam/services/image_resizer_service.rb @@ -5,13 +5,13 @@ class ImageResizerService attr_accessor_initialize :resizer, :asset_path - def resize(source, geometry, convert = "") + def resize(source, geometry, convert_args = "") return get_url_or_path(source) if disabled? || geometry.blank? if file = fetch_file(source) - transformed_file = file.thumb(geometry) - transformed_file = transformed_file.convert(convert) if !convert.blank? - transformed_file.url + job = file.thumb(geometry) + job = image_magick_convert(job, convert_args) + job.url else Locomotive::Common::Logger.error "Unable to resize on the fly: #{source.inspect}" nil @@ -47,6 +47,11 @@ def get_url_or_path(source) value.strip if value end + def image_magick_convert(job, options = '') + return job if options.blank? + job.process(:convert, options) + end + end end diff --git a/locomotivecms_steam.gemspec b/locomotivecms_steam.gemspec index ce9c6c29..9f948dfa 100644 --- a/locomotivecms_steam.gemspec +++ b/locomotivecms_steam.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'rack-cache', '>= 1.7', '< 2' spec.add_dependency 'rack-session', '~> 2.0.0' spec.add_dependency 'rack_csrf', '~> 2.6.0' - spec.add_dependency 'dragonfly', '>= 1.2', '< 1.5' + spec.add_dependency 'dragonfly', '~> 1.4.0' spec.add_dependency 'moneta', '~> 1.6.0' spec.add_dependency 'execjs', '~> 2.9.1'