image_processing 1.12.2 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31d06cb35ac94ec0787b21dd2118626f3a3a96685efab0d7eb58d9079b1fbf2c
4
- data.tar.gz: 8f840074b8fe9511e59f4f005d144e39c9aba4d0699a48c29ffc6cb2513ec645
3
+ metadata.gz: fa60a0e94436db0e6f672a321162282b92fff25b9acac0031d11f8e75bd46bee
4
+ data.tar.gz: f6f2cc0a61658d8a3db0883b4bdf7b9ec6421d29b74ce22ca1fee5ea2ff58d94
5
5
  SHA512:
6
- metadata.gz: 1d0fb1d9363b9b85e1895d05849a5c29b2c50b8213bf9e9d6ff8c2e1391a9bf6448a4e319a4cfd747183ec741ac42d6b1b1b9629ee91d97cc4a287ec6615042c
7
- data.tar.gz: dd31dd0ca012ceb35aa276c5e00efd3e9bd2c40246f9b063ea39280ea13c546373fa641518fb55ebcf0e9d00ad6020be995b8d8636c8a3939bda31c643485cef
6
+ metadata.gz: 7220163f9f2572070de49f84ac4a9051433c504c44c6925660bcac162855b38920691d6e661deeeee3b2b6238f8a78cc4881dd10e539136bf02bef01ff05cca0
7
+ data.tar.gz: 9b21b5d109a9e7f8b116cccbf347809a2943171e959e8c1efc9797fcc133759c34ee83148601aa3f413f7e972b12a1803b4229f2b27835c35ab745fe39b0011f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
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
+
1
9
  ## 1.12.2 (2022-03-01)
2
10
 
3
11
  * Prevent remote shell execution when using `#apply` with operations coming from user input (@janko)
data/README.md CHANGED
@@ -30,7 +30,7 @@ how to resize and process images.
30
30
  1. Install ImageMagick and/or libvips:
31
31
 
32
32
  In a Mac terminal:
33
-
33
+
34
34
  ```sh
35
35
  $ brew install imagemagick vips
36
36
  ```
@@ -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
- magick.merge! args
160
+ if args.empty?
161
+ magick.append
162
+ else
163
+ magick.merge! args
164
+ end
155
165
  end
156
166
 
157
167
  private
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "1.12.2"
2
+ VERSION = "1.13.0"
3
3
  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
- image.similarity(angle: degrees, **options)
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.12.2
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -159,7 +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.3.3
162
+ rubygems_version: 3.5.11
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: High-level wrapper for processing images for the web with ImageMagick or