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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/image_processing/mini_magick.rb +12 -7
- data/lib/image_processing/version.rb +1 -1
- data/lib/image_processing/vips.rb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91616e1f059395f4197125f345f097948f04bdabb08737c95155856aa267885e
|
4
|
+
data.tar.gz: f7d33fce924062960e4ac5dae9019df37374b6ae1ca9c0f97dc8e5fe66400860
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
@@ -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,
|
52
|
+
def rotate(image, degrees, background: nil)
|
53
53
|
if degrees % 90 == 0
|
54
54
|
image.rot(:"d#{degrees % 360}")
|
55
55
|
else
|
56
|
-
|
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.
|
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-
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|