jr-paperclip 7.3.1 → 8.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +3 -1
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -0
- data/NEWS +13 -0
- data/README.md +116 -6
- data/UPGRADING +5 -0
- data/VIPS_MIGRATION_GUIDE.md +131 -0
- data/features/basic_integration.feature +27 -0
- data/features/step_definitions/attachment_steps.rb +17 -0
- data/gemfiles/7.0.gemfile +1 -0
- data/gemfiles/7.1.gemfile +1 -0
- data/gemfiles/7.2.gemfile +1 -0
- data/gemfiles/8.0.gemfile +1 -0
- data/gemfiles/8.1.gemfile +1 -0
- data/lib/paperclip/attachment.rb +3 -2
- data/lib/paperclip/errors.rb +4 -5
- data/lib/paperclip/geometry.rb +3 -3
- data/lib/paperclip/geometry_detector_factory.rb +52 -12
- data/lib/paperclip/helpers.rb +18 -0
- data/lib/paperclip/processor.rb +36 -4
- data/lib/paperclip/thumbnail.rb +568 -62
- data/lib/paperclip/version.rb +1 -1
- data/lib/paperclip.rb +26 -9
- data/paperclip.gemspec +2 -1
- data/spec/paperclip/attachment_definitions_spec.rb +300 -0
- data/spec/paperclip/attachment_spec.rb +1 -1
- data/spec/paperclip/geometry_detector_spec.rb +81 -32
- data/spec/paperclip/geometry_spec.rb +8 -5
- data/spec/paperclip/helpers_spec.rb +49 -0
- data/spec/paperclip/lazy_thumbnail_compatibility_spec.rb +266 -0
- data/spec/paperclip/processor_spec.rb +35 -1
- data/spec/paperclip/style_spec.rb +58 -0
- data/spec/paperclip/thumbnail_custom_options_spec.rb +173 -0
- data/spec/paperclip/thumbnail_loader_options_spec.rb +53 -0
- data/spec/paperclip/thumbnail_security_spec.rb +42 -0
- data/spec/paperclip/thumbnail_spec.rb +1127 -172
- metadata +34 -2
data/lib/paperclip/processor.rb
CHANGED
|
@@ -36,10 +36,18 @@ module Paperclip
|
|
|
36
36
|
# The convert method runs the convert binary with the provided arguments.
|
|
37
37
|
# See Paperclip.run for the available options.
|
|
38
38
|
def convert(arguments = "", local_options = {})
|
|
39
|
+
command =
|
|
40
|
+
if Paperclip.imagemagick7? # IMv7 on any OS
|
|
41
|
+
"magick"
|
|
42
|
+
elsif Paperclip.options[:is_windows] # IMv6 on Windows
|
|
43
|
+
"magick convert"
|
|
44
|
+
else
|
|
45
|
+
"convert"
|
|
46
|
+
end
|
|
39
47
|
Paperclip.run(
|
|
40
|
-
|
|
48
|
+
command,
|
|
41
49
|
arguments,
|
|
42
|
-
local_options
|
|
50
|
+
local_options,
|
|
43
51
|
)
|
|
44
52
|
end
|
|
45
53
|
|
|
@@ -47,10 +55,34 @@ module Paperclip
|
|
|
47
55
|
# See Paperclip.run for the available options.
|
|
48
56
|
def identify(arguments = "", local_options = {})
|
|
49
57
|
Paperclip.run(
|
|
50
|
-
Paperclip.options[:is_windows] ? "magick identify" : "identify",
|
|
58
|
+
(Paperclip.options[:is_windows] || Paperclip.imagemagick7?) ? "magick identify" : "identify",
|
|
51
59
|
arguments,
|
|
52
|
-
local_options
|
|
60
|
+
local_options,
|
|
53
61
|
)
|
|
54
62
|
end
|
|
63
|
+
|
|
64
|
+
# Runs libvips command
|
|
65
|
+
def vips(arguments = "", local_options = {})
|
|
66
|
+
Paperclip.run("vips", arguments, local_options)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Runs libvips header command
|
|
70
|
+
def vipsheader(arguments = "", local_options = {})
|
|
71
|
+
Paperclip.run("vipsheader", arguments, local_options)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Returns a Vips::Image object for the given file path.
|
|
75
|
+
# This provides access to the full ruby-vips API for image manipulation.
|
|
76
|
+
# @param file_path [String] Path to the image file
|
|
77
|
+
# @param options [Hash] Options to pass to Vips::Image.new_from_file
|
|
78
|
+
# @return [Vips::Image] The loaded image
|
|
79
|
+
def vips_image(file_path, **options)
|
|
80
|
+
begin
|
|
81
|
+
require "vips"
|
|
82
|
+
rescue LoadError
|
|
83
|
+
raise Errors::CommandNotFoundError.new("Could not load ruby-vips. Please install libvips and the vips gem.")
|
|
84
|
+
end
|
|
85
|
+
Vips::Image.new_from_file(file_path, **options)
|
|
86
|
+
end
|
|
55
87
|
end
|
|
56
88
|
end
|