image_processing 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of image_processing might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 164c6848e86e4376b4c0d71be8b73b63554c4df72b9a86c856feae6d641a74b8
4
- data.tar.gz: e460f863d946846e03490b11bf2bbd8af6d23dd726568c5fc3c84521c78c1904
3
+ metadata.gz: 91616e1f059395f4197125f345f097948f04bdabb08737c95155856aa267885e
4
+ data.tar.gz: f7d33fce924062960e4ac5dae9019df37374b6ae1ca9c0f97dc8e5fe66400860
5
5
  SHA512:
6
- metadata.gz: ce69d381344f78eb7d86a69d21638c05a871971b0a968fd31ea728b7f6f2586e890ff8e422886a7af6120bdfba950e719ab24fc7ad9195b89bb2ffd4dbd22e79
7
- data.tar.gz: 457acb598fb187d5957a55aaf79cba435f3a9ea9c55412a7840ab88e575abb6f47a3d6cd7c8313ce1ae570ddce64af666f419d7516adc176aac891efb6b6766c
6
+ metadata.gz: 701f320524f7753255ebf6601196dc0c3c6c81bb52ae2f3c92ccb05850e1ef6ae18e9c31dd271a0d8b3d6bd8b727b9c2e8757feda2d024df957f40126ac7799f
7
+ data.tar.gz: 07c799fe3f6a430177ca426280181343315a7e17ba28d74b2feb3bf047f1d263fefa5c3663594daa733f7448872ba03ef64208fafd2e1b6c721f680dad02c58b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.4.0 (2018-06-14)
2
+
3
+ * [minimagick] Accept RGB(A) arrays for color names for `:background` (@janko-m)
4
+
5
+ * [minimagick] Don't add empty `-background` option in `#rotate` when `:background` is not given (@janko-m)
6
+
7
+ * [vips] Modify `#rotate` to accept only `:background` and not other `vips_similarity()` options (@janko-m)
8
+
1
9
  ## 1.3.0 (2018-06-13)
2
10
 
3
11
  * [minimagick, vips] Add `#rotate` function (@janko-m)
@@ -30,23 +30,19 @@ module ImageProcessing
30
30
  def resize_to_fill(magick, width, height, gravity: "Center", **options)
31
31
  thumbnail(magick, "#{width}x#{height}^", **options)
32
32
  magick.gravity gravity
33
- magick.background "rgba(255,255,255,0.0)" # transparent
33
+ magick.background color(:transparent)
34
34
  magick.extent "#{width}x#{height}"
35
35
  end
36
36
 
37
37
  def resize_and_pad(magick, width, height, background: :transparent, gravity: "Center", **options)
38
- background = "rgba(255,255,255,0.0)" if background.to_s == "transparent"
39
-
40
38
  thumbnail(magick, "#{width}x#{height}", **options)
41
- magick.background background
39
+ magick.background color(background)
42
40
  magick.gravity gravity
43
41
  magick.extent "#{width}x#{height}"
44
42
  end
45
43
 
46
44
  def rotate(magick, degrees, background: nil)
47
- background = "rgba(255,255,255,0.0)" if background.to_s == "transparent"
48
-
49
- magick.background background
45
+ magick.background color(background) if background
50
46
  magick.rotate(degrees)
51
47
  end
52
48
 
@@ -106,6 +102,15 @@ module ImageProcessing
106
102
 
107
103
  private
108
104
 
105
+ def color(value)
106
+ return "rgba(255,255,255,0.0)" if value.to_s == "transparent"
107
+ return "rgb(#{value.join(",")})" if value.is_a?(Array) && value.count == 3
108
+ return "rgba(#{value.join(",")})" if value.is_a?(Array) && value.count == 4
109
+ return value if value.is_a?(String)
110
+
111
+ raise ArgumentError, "unrecognized color format: #{value.inspect} (must be one of: string, 3-element RGB array, 4-element RGBA array)"
112
+ end
113
+
109
114
  def thumbnail(magick, geometry, sharpen: {})
110
115
  magick.resize(geometry)
111
116
  magick.sharpen(sharpen_value(sharpen)) if sharpen
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -49,11 +49,14 @@ module ImageProcessing
49
49
  image.gravity(gravity, width, height, **embed_options)
50
50
  end
51
51
 
52
- def rotate(image, degrees, **options)
52
+ def rotate(image, degrees, background: nil)
53
53
  if degrees % 90 == 0
54
54
  image.rot(:"d#{degrees % 360}")
55
55
  else
56
- image.similarity(angle: degrees, **options)
56
+ options = { angle: degrees }
57
+ options[:background] = background if background
58
+
59
+ image.similarity(**options)
57
60
  end
58
61
  end
59
62
 
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.3.0
4
+ version: 1.4.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: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2018-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick