image_processing 1.2.0 → 1.3.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: 39c52030a178edeef33439eb70807d86935b1e05bbf250d0f30aa9a4947f6dea
4
- data.tar.gz: 60c936577febb87380de300024a8f4517ae9dafed394d74fe7b0f78ab04efd7f
3
+ metadata.gz: 164c6848e86e4376b4c0d71be8b73b63554c4df72b9a86c856feae6d641a74b8
4
+ data.tar.gz: e460f863d946846e03490b11bf2bbd8af6d23dd726568c5fc3c84521c78c1904
5
5
  SHA512:
6
- metadata.gz: 9bc68c91084d44b3052a47ac332d21840965537163b541ef09cd662d729c26e152b3e588f97fd954a13aaae0a5a645be86389a79308de4eee154feb7fed95baa
7
- data.tar.gz: 4c026c8eb9cc4dfa537ef3f0f86b460a8dc0a13134fe441604483b6a4b1afd1048911b499673807fac82f7a15c37773e27fad1dd2d049f8e8adedd5204166923
6
+ metadata.gz: ce69d381344f78eb7d86a69d21638c05a871971b0a968fd31ea728b7f6f2586e890ff8e422886a7af6120bdfba950e719ab24fc7ad9195b89bb2ffd4dbd22e79
7
+ data.tar.gz: 457acb598fb187d5957a55aaf79cba435f3a9ea9c55412a7840ab88e575abb6f47a3d6cd7c8313ce1ae570ddce64af666f419d7516adc176aac891efb6b6766c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.3.0 (2018-06-13)
2
+
3
+ * [minimagick, vips] Add `#rotate` function (@janko-m)
4
+
5
+ * [vips] Use native `vips_image_hasalpha()` and `vips_addalpha()` functions in `#resize_and_pad` (@janko-m)
6
+
1
7
  ## 1.2.0 (2018-04-18)
2
8
 
3
9
  * [minimagick] Allow appending "+" operators in `#loader` and `#saver` using the value `false` (@janko-m)
@@ -46,8 +52,6 @@
46
52
 
47
53
  * [vips] Fix `:alpha` not correctly adding alpha for certain types of images (@janko-m)
48
54
 
49
- * [minimagick] Drop official support for GraphicsMagick (@janko-m)
50
-
51
55
  ## 0.11.1 (2018-03-27)
52
56
 
53
57
  * [minimagick] Rename `#limit` to `#limits` to still allow adding `-limit` arguments directly (@janko-m)
data/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  Provides higher-level image processing helpers that are commonly needed
4
4
  when handling image uploads.
5
5
 
6
- This gem can process images with either [ImageMagick] or [libvips] libraries.
7
- ImageMagick is a good default choice, especially if you are migrating from
8
- another gem or library that uses ImageMagick. Libvips is a newer library that
9
- can process images [very rapidly][libvips performance] (up to 10x faster than
10
- ImageMagick).
6
+ This gem can process images with either [ImageMagick]/[GraphicsMagick] or
7
+ [libvips] libraries. ImageMagick is a good default choice, especially if you
8
+ are migrating from another gem or library that uses ImageMagick. Libvips is a
9
+ newer library that can process images [very rapidly][libvips performance] (up
10
+ to 10x faster than ImageMagick).
11
11
 
12
12
 
13
13
  ## Goal
@@ -117,7 +117,8 @@ pipeline.options
117
117
  ```
118
118
 
119
119
  The source object needs to responds to `#path`, or be a String, a Pathname, or
120
- a `Vips::Image`/`MiniMagick::Tool` object.
120
+ a `Vips::Image`/`MiniMagick::Tool` object. Note that the processed file is
121
+ always saved to a new location, in-place processing is not supported.
121
122
 
122
123
  ```rb
123
124
  ImageProcessing::Vips.source(File.open("source.jpg"))
@@ -144,7 +145,8 @@ You can continue reading the API documentation for specific modules:
144
145
  * **[`ImageProcessing::Vips`]**
145
146
  * **[`ImageProcessing::MiniMagick`]**
146
147
 
147
- See the **[wiki]** for additional "How To" guides for common scenarios.
148
+ See the **[wiki]** for additional "How To" guides for common scenarios. The wiki
149
+ is publicly editable, so you're encouraged to add your own guides.
148
150
 
149
151
 
150
152
  ## Contributing
@@ -181,6 +183,7 @@ The `ImageProcessing::MiniMagick` functionality was extracted from
181
183
 
182
184
  [libvips]: http://jcupitt.github.io/libvips/
183
185
  [ImageMagick]: https://www.imagemagick.org
186
+ [GraphicsMagick]: http://www.graphicsmagick.org
184
187
  [`ImageProcessing::Vips`]: /doc/vips.md#imageprocessingvips
185
188
  [`ImageProcessing::MiniMagick`]: /doc/minimagick.md#imageprocessingminimagick
186
189
  [refile-mini_magick]: https://github.com/refile/refile-mini_magick
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_dependency "mini_magick", "~> 4.0"
20
- spec.add_dependency "ruby-vips", ">= 2.0.10", "< 3"
20
+ spec.add_dependency "ruby-vips", ">= 2.0.11", "< 3"
21
21
 
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "minitest", "~> 5.8"
@@ -43,13 +43,20 @@ module ImageProcessing
43
43
  magick.extent "#{width}x#{height}"
44
44
  end
45
45
 
46
+ def rotate(magick, degrees, background: nil)
47
+ background = "rgba(255,255,255,0.0)" if background.to_s == "transparent"
48
+
49
+ magick.background background
50
+ magick.rotate(degrees)
51
+ end
52
+
46
53
  def define(magick, options)
47
54
  return magick.define(options) if options.is_a?(String)
48
55
 
49
- options.each do |namespace, options|
56
+ options.each do |namespace, settings|
50
57
  namespace = namespace.to_s.gsub("_", "-")
51
58
 
52
- options.each do |key, value|
59
+ settings.each do |key, value|
53
60
  key = key.to_s.gsub("_", "-")
54
61
 
55
62
  magick.define "#{namespace}:#{key}=#{value}"
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -45,10 +45,18 @@ module ImageProcessing
45
45
  embed_options.reject! { |name, value| value.nil? }
46
46
 
47
47
  image = thumbnail(image, width, height, **options)
48
- image = add_alpha(image) if alpha && !has_alpha?(image)
48
+ image = image.add_alpha if alpha && !image.has_alpha?
49
49
  image.gravity(gravity, width, height, **embed_options)
50
50
  end
51
51
 
52
+ def rotate(image, degrees, **options)
53
+ if degrees % 90 == 0
54
+ image.rot(:"d#{degrees % 360}")
55
+ else
56
+ image.similarity(angle: degrees, **options)
57
+ end
58
+ end
59
+
52
60
  def load_image(path_or_image, autorot: true, **options)
53
61
  if path_or_image.is_a?(::Vips::Image)
54
62
  image = path_or_image
@@ -78,19 +86,6 @@ module ImageProcessing
78
86
  image
79
87
  end
80
88
 
81
- # Port of libvips' vips_addalpha().
82
- def add_alpha(image)
83
- max_alpha = (image.interpretation == :grey16 || image.interpretation == :rgb16) ? 65535 : 255
84
- image.bandjoin(max_alpha)
85
- end
86
-
87
- # Port of libvips' vips_hasalpha().
88
- def has_alpha?(image)
89
- image.bands == 2 ||
90
- (image.bands == 4 && image.interpretation != :cmyk) ||
91
- image.bands > 4
92
- end
93
-
94
89
  def default_dimensions(width, height)
95
90
  raise Error, "either width or height must be specified" unless width || height
96
91
 
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.2.0
4
+ version: 1.3.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-04-18 00:00:00.000000000 Z
11
+ date: 2018-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.10
33
+ version: 2.0.11
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '3'
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 2.0.10
43
+ version: 2.0.11
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '3'