image_processing 1.12.0 → 1.13.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 +16 -0
- data/README.md +16 -1
- data/image_processing.gemspec +1 -1
- data/lib/image_processing/chainable.rb +7 -5
- data/lib/image_processing/mini_magick.rb +11 -1
- data/lib/image_processing/pipeline.rb +8 -2
- data/lib/image_processing/version.rb +1 -1
- data/lib/image_processing/vips.rb +23 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa60a0e94436db0e6f672a321162282b92fff25b9acac0031d11f8e75bd46bee
|
4
|
+
data.tar.gz: f6f2cc0a61658d8a3db0883b4bdf7b9ec6421d29b74ce22ca1fee5ea2ff58d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7220163f9f2572070de49f84ac4a9051433c504c44c6925660bcac162855b38920691d6e661deeeee3b2b6238f8a78cc4881dd10e539136bf02bef01ff05cca0
|
7
|
+
data.tar.gz: 9b21b5d109a9e7f8b116cccbf347809a2943171e959e8c1efc9797fcc133759c34ee83148601aa3f413f7e972b12a1803b4229f2b27835c35ab745fe39b0011f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 1.13.0 (2024-07-24)
|
2
|
+
|
3
|
+
* [minimagick] Use `-append` when calling `#append` with no arguments (@janko)
|
4
|
+
|
5
|
+
* [vips] Avoid lines on the side when rotating by multiples of 90 degrees (@etherbob)
|
6
|
+
|
7
|
+
* Add `#resize_to_cover` that allows resizing an image to cover a given rectangle without cropping the excess (@brendon)
|
8
|
+
|
9
|
+
## 1.12.2 (2022-03-01)
|
10
|
+
|
11
|
+
* Prevent remote shell execution when using `#apply` with operations coming from user input (@janko)
|
12
|
+
|
13
|
+
## 1.12.1 (2020-11-06)
|
14
|
+
|
15
|
+
* Fix format fallback for files ending with a dot on Ruby 2.7+ (@coding-chimp)
|
16
|
+
|
1
17
|
## 1.12.0 (2020-09-20)
|
2
18
|
|
3
19
|
* Add instrumentation support via `#instrumenter` (@janko)
|
data/README.md
CHANGED
@@ -29,10 +29,18 @@ how to resize and process images.
|
|
29
29
|
|
30
30
|
1. Install ImageMagick and/or libvips:
|
31
31
|
|
32
|
-
|
32
|
+
In a Mac terminal:
|
33
|
+
|
34
|
+
```sh
|
33
35
|
$ brew install imagemagick vips
|
34
36
|
```
|
35
37
|
|
38
|
+
In a debian/ubuntu terminal:
|
39
|
+
|
40
|
+
```sh
|
41
|
+
$ sudo apt install imagemagick libvips
|
42
|
+
```
|
43
|
+
|
36
44
|
2. Add the gem to your Gemfile:
|
37
45
|
|
38
46
|
```rb
|
@@ -181,10 +189,17 @@ pipeline
|
|
181
189
|
|
182
190
|
Our test suite requires both `imagemagick` and `libvips` libraries to be installed.
|
183
191
|
|
192
|
+
In a Mac terminal:
|
193
|
+
|
184
194
|
```
|
185
195
|
$ brew install imagemagick vips
|
186
196
|
```
|
187
197
|
|
198
|
+
In a debian/ubuntu terminal:
|
199
|
+
```shell
|
200
|
+
sudo apt install imagemagick libvips
|
201
|
+
```
|
202
|
+
|
188
203
|
Afterwards you can run tests with
|
189
204
|
|
190
205
|
```
|
data/image_processing.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.8"
|
24
24
|
spec.add_development_dependency "minitest-hooks", ">= 1.4.2"
|
25
25
|
spec.add_development_dependency "minispec-metadata"
|
26
|
-
spec.add_development_dependency "
|
26
|
+
spec.add_development_dependency "dhash-vips"
|
27
27
|
end
|
@@ -34,13 +34,13 @@ module ImageProcessing
|
|
34
34
|
def apply(operations)
|
35
35
|
operations.inject(self) do |builder, (name, argument)|
|
36
36
|
if argument == true || argument == nil
|
37
|
-
builder.
|
37
|
+
builder.public_send(name)
|
38
38
|
elsif argument.is_a?(Array)
|
39
|
-
builder.
|
39
|
+
builder.public_send(name, *argument)
|
40
40
|
elsif argument.is_a?(Hash)
|
41
|
-
builder.
|
41
|
+
builder.public_send(name, **argument)
|
42
42
|
else
|
43
|
-
builder.
|
43
|
+
builder.public_send(name, argument)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -53,7 +53,9 @@ module ImageProcessing
|
|
53
53
|
# Call the defined processing and get the result. Allows specifying
|
54
54
|
# the source file and destination.
|
55
55
|
def call(file = nil, destination: nil, **call_options)
|
56
|
-
options = {
|
56
|
+
options = {}
|
57
|
+
options[:source] = file if file
|
58
|
+
options[:destination] = destination if destination
|
57
59
|
|
58
60
|
branch(**options).call!(**call_options)
|
59
61
|
end
|
@@ -86,6 +86,12 @@ module ImageProcessing
|
|
86
86
|
magick.extent "#{width}x#{height}"
|
87
87
|
end
|
88
88
|
|
89
|
+
# Resizes the image to cover the specified dimensions, without
|
90
|
+
# cropping the excess.
|
91
|
+
def resize_to_cover(width, height, **options)
|
92
|
+
thumbnail("#{width}x#{height}^", **options)
|
93
|
+
end
|
94
|
+
|
89
95
|
# Crops the image with the specified crop points.
|
90
96
|
def crop(*args)
|
91
97
|
case args.count
|
@@ -151,7 +157,11 @@ module ImageProcessing
|
|
151
157
|
|
152
158
|
# Appends a raw ImageMagick command-line argument to the command.
|
153
159
|
def append(*args)
|
154
|
-
|
160
|
+
if args.empty?
|
161
|
+
magick.append
|
162
|
+
else
|
163
|
+
magick.merge! args
|
164
|
+
end
|
155
165
|
end
|
156
166
|
|
157
167
|
private
|
@@ -37,9 +37,9 @@ module ImageProcessing
|
|
37
37
|
|
38
38
|
# Determines the appropriate destination image format.
|
39
39
|
def destination_format
|
40
|
-
format =
|
40
|
+
format = determine_format(destination) if destination
|
41
41
|
format ||= self.format
|
42
|
-
format ||=
|
42
|
+
format ||= determine_format(source_path) if source_path
|
43
43
|
|
44
44
|
format || DEFAULT_FORMAT
|
45
45
|
end
|
@@ -93,5 +93,11 @@ module ImageProcessing
|
|
93
93
|
@source
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
def determine_format(file_path)
|
98
|
+
extension = File.extname(file_path)
|
99
|
+
|
100
|
+
extension[1..-1] if extension.size > 1
|
101
|
+
end
|
96
102
|
end
|
97
103
|
end
|
@@ -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) ? ::Vips::Image.new_from_file(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,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
|
-
name:
|
110
|
+
name: dhash-vips
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
@@ -144,7 +144,7 @@ homepage: https://github.com/janko/image_processing
|
|
144
144
|
licenses:
|
145
145
|
- MIT
|
146
146
|
metadata: {}
|
147
|
-
post_install_message:
|
147
|
+
post_install_message:
|
148
148
|
rdoc_options: []
|
149
149
|
require_paths:
|
150
150
|
- lib
|
@@ -159,8 +159,8 @@ 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.5.11
|
163
|
+
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: High-level wrapper for processing images for the web with ImageMagick or
|
166
166
|
libvips.
|