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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +3 -1
  3. data/CONTRIBUTING.md +1 -1
  4. data/Gemfile +1 -0
  5. data/NEWS +13 -0
  6. data/README.md +116 -6
  7. data/UPGRADING +5 -0
  8. data/VIPS_MIGRATION_GUIDE.md +131 -0
  9. data/features/basic_integration.feature +27 -0
  10. data/features/step_definitions/attachment_steps.rb +17 -0
  11. data/gemfiles/7.0.gemfile +1 -0
  12. data/gemfiles/7.1.gemfile +1 -0
  13. data/gemfiles/7.2.gemfile +1 -0
  14. data/gemfiles/8.0.gemfile +1 -0
  15. data/gemfiles/8.1.gemfile +1 -0
  16. data/lib/paperclip/attachment.rb +3 -2
  17. data/lib/paperclip/errors.rb +4 -5
  18. data/lib/paperclip/geometry.rb +3 -3
  19. data/lib/paperclip/geometry_detector_factory.rb +52 -12
  20. data/lib/paperclip/helpers.rb +18 -0
  21. data/lib/paperclip/processor.rb +36 -4
  22. data/lib/paperclip/thumbnail.rb +568 -62
  23. data/lib/paperclip/version.rb +1 -1
  24. data/lib/paperclip.rb +26 -9
  25. data/paperclip.gemspec +2 -1
  26. data/spec/paperclip/attachment_definitions_spec.rb +300 -0
  27. data/spec/paperclip/attachment_spec.rb +1 -1
  28. data/spec/paperclip/geometry_detector_spec.rb +81 -32
  29. data/spec/paperclip/geometry_spec.rb +8 -5
  30. data/spec/paperclip/helpers_spec.rb +49 -0
  31. data/spec/paperclip/lazy_thumbnail_compatibility_spec.rb +266 -0
  32. data/spec/paperclip/processor_spec.rb +35 -1
  33. data/spec/paperclip/style_spec.rb +58 -0
  34. data/spec/paperclip/thumbnail_custom_options_spec.rb +173 -0
  35. data/spec/paperclip/thumbnail_loader_options_spec.rb +53 -0
  36. data/spec/paperclip/thumbnail_security_spec.rb +42 -0
  37. data/spec/paperclip/thumbnail_spec.rb +1127 -172
  38. metadata +34 -2
@@ -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
- Paperclip.options[:is_windows] ? "magick convert" : "convert",
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