image_processing 1.12.2 → 1.14.0
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/CHANGELOG.md +14 -0
- data/README.md +1 -1
- data/image_processing.gemspec +4 -1
- data/lib/image_processing/mini_magick.rb +21 -3
- data/lib/image_processing/version.rb +1 -1
- data/lib/image_processing/vips.rb +23 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613676364c0ba04b655a087a89296cec4604c8f362809ada23d984538f9e962b
|
4
|
+
data.tar.gz: 77a768424b857418d131257ce2c539715aa69999da7e78319255d9eee3f68157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2e1a9bf128d872ad2c5663525c4e970e8b18457f2b4f0a50588a9f33c736b0ef46a3fb4bd10638be5a276e9aa8bacbae09c9685b954416902de3687a3b2181
|
7
|
+
data.tar.gz: c7efff88134c14c44001ea99ed7632ecc86b93bd3afe5e933cfdc8cb2d57a82fc69333192777ac17cdf9e5bf5ef15e012c17e6c7dffbd7124ed58d765e4bff4b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 1.14.0 (2025-02-10)
|
2
|
+
|
3
|
+
* Add support for MiniMagick 5.x (@lukeasrodgers)
|
4
|
+
|
5
|
+
* Fix `#resize_to_cover` when dealing with EXIF orientated images (@brendon)
|
6
|
+
|
7
|
+
## 1.13.0 (2024-07-24)
|
8
|
+
|
9
|
+
* [minimagick] Use `-append` when calling `#append` with no arguments (@janko)
|
10
|
+
|
11
|
+
* [vips] Avoid lines on the side when rotating by multiples of 90 degrees (@etherbob)
|
12
|
+
|
13
|
+
* Add `#resize_to_cover` that allows resizing an image to cover a given rectangle without cropping the excess (@brendon)
|
14
|
+
|
1
15
|
## 1.12.2 (2022-03-01)
|
2
16
|
|
3
17
|
* Prevent remote shell execution when using `#apply` with operations coming from user input (@janko)
|
data/README.md
CHANGED
data/image_processing.gemspec
CHANGED
@@ -16,7 +16,10 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*.rb", "*.gemspec"]
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.
|
19
|
+
spec.metadata = { "changelog_uri" => spec.homepage + "/blob/master/CHANGELOG.md",
|
20
|
+
"rubygems_mfa_required" => "true" }
|
21
|
+
|
22
|
+
spec.add_dependency "mini_magick", ">= 4.9.5", "< 6"
|
20
23
|
spec.add_dependency "ruby-vips", ">= 2.0.17", "< 3"
|
21
24
|
|
22
25
|
spec.add_development_dependency "rake"
|
@@ -5,9 +5,17 @@ module ImageProcessing
|
|
5
5
|
module MiniMagick
|
6
6
|
extend Chainable
|
7
7
|
|
8
|
+
def self.convert_shim(&block)
|
9
|
+
if ::MiniMagick.respond_to?(:convert)
|
10
|
+
::MiniMagick.convert(&block)
|
11
|
+
else
|
12
|
+
::MiniMagick::Tool::Convert.new(&block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
# Returns whether the given image file is processable.
|
9
17
|
def self.valid_image?(file)
|
10
|
-
|
18
|
+
convert_shim do |convert|
|
11
19
|
convert << file.path
|
12
20
|
convert << "null:"
|
13
21
|
end
|
@@ -30,7 +38,7 @@ module ImageProcessing
|
|
30
38
|
magick = path_or_magick
|
31
39
|
else
|
32
40
|
source_path = path_or_magick
|
33
|
-
magick = ::MiniMagick
|
41
|
+
magick = ::ImageProcessing::MiniMagick.convert_shim
|
34
42
|
|
35
43
|
Utils.apply_options(magick, **options)
|
36
44
|
|
@@ -86,6 +94,12 @@ module ImageProcessing
|
|
86
94
|
magick.extent "#{width}x#{height}"
|
87
95
|
end
|
88
96
|
|
97
|
+
# Resizes the image to cover the specified dimensions, without
|
98
|
+
# cropping the excess.
|
99
|
+
def resize_to_cover(width, height, **options)
|
100
|
+
thumbnail("#{width}x#{height}^", **options)
|
101
|
+
end
|
102
|
+
|
89
103
|
# Crops the image with the specified crop points.
|
90
104
|
def crop(*args)
|
91
105
|
case args.count
|
@@ -151,7 +165,11 @@ module ImageProcessing
|
|
151
165
|
|
152
166
|
# Appends a raw ImageMagick command-line argument to the command.
|
153
167
|
def append(*args)
|
154
|
-
|
168
|
+
if args.empty?
|
169
|
+
magick.append
|
170
|
+
else
|
171
|
+
magick.merge! args
|
172
|
+
end
|
155
173
|
end
|
156
174
|
|
157
175
|
private
|
@@ -90,9 +90,31 @@ module ImageProcessing
|
|
90
90
|
image.gravity(gravity, width, height, extend: extend, background: background)
|
91
91
|
end
|
92
92
|
|
93
|
+
# Resizes the image to cover the specified dimensions, without
|
94
|
+
# cropping the excess.
|
95
|
+
def resize_to_cover(width, height, **options)
|
96
|
+
image = self.image.is_a?(String) ? self.class.load_image(self.image) : self.image
|
97
|
+
|
98
|
+
image_ratio = Rational(image.width, image.height)
|
99
|
+
thumbnail_ratio = Rational(width, height)
|
100
|
+
|
101
|
+
if image_ratio > thumbnail_ratio
|
102
|
+
width = ::Vips::MAX_COORD
|
103
|
+
else
|
104
|
+
height = ::Vips::MAX_COORD
|
105
|
+
end
|
106
|
+
|
107
|
+
thumbnail(width, height, **options, crop: :none)
|
108
|
+
end
|
109
|
+
|
93
110
|
# Rotates the image by an arbitrary angle.
|
94
111
|
def rotate(degrees, **options)
|
95
|
-
|
112
|
+
if ([90, 180, 270].include?(degrees) && options.empty?)
|
113
|
+
rot_command = "rot#{degrees}".to_sym
|
114
|
+
image.public_send rot_command
|
115
|
+
else
|
116
|
+
image.similarity(angle: degrees, **options)
|
117
|
+
end
|
96
118
|
end
|
97
119
|
|
98
120
|
# Overlays the specified image over the current one. Supports specifying
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-10 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: mini_magick
|
@@ -19,7 +18,7 @@ dependencies:
|
|
19
18
|
version: 4.9.5
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '6'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +28,7 @@ dependencies:
|
|
29
28
|
version: 4.9.5
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
31
|
+
version: '6'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: ruby-vips
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,8 +142,9 @@ files:
|
|
143
142
|
homepage: https://github.com/janko/image_processing
|
144
143
|
licenses:
|
145
144
|
- MIT
|
146
|
-
metadata:
|
147
|
-
|
145
|
+
metadata:
|
146
|
+
changelog_uri: https://github.com/janko/image_processing/blob/master/CHANGELOG.md
|
147
|
+
rubygems_mfa_required: 'true'
|
148
148
|
rdoc_options: []
|
149
149
|
require_paths:
|
150
150
|
- lib
|
@@ -159,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
163
|
-
signing_key:
|
162
|
+
rubygems_version: 3.6.2
|
164
163
|
specification_version: 4
|
165
164
|
summary: High-level wrapper for processing images for the web with ImageMagick or
|
166
165
|
libvips.
|