image_processing 0.3.0 → 0.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
  SHA1:
3
- metadata.gz: af4532e0d6a06a00ac95a2c5f7190e4df6a4e891
4
- data.tar.gz: 3a639bcbaa104a55a5d2387d4c4cfdeaaf5149ae
3
+ metadata.gz: 7bc54f7a1d6be87dbe3a80c984e02a47151dbdb3
4
+ data.tar.gz: 1c6aa1a4933a1da16aa3b39d87295694d5bc0a2c
5
5
  SHA512:
6
- metadata.gz: 279b62385e8c5b7edb4baa3c749063dd8e40a03ceaee7216f6a9db3377287337c63b301935f95a3ca715b30f52fadff642484e42100a60acd7c5c1bff79a075e
7
- data.tar.gz: 876bc51156893cd604d17ab8b1d2954f92136fea590b93e809575f44ba98ef6c1509bb6657ba2f6797ce32816aa7da0201710a5c620b56e64af1a61134bfbae4
6
+ metadata.gz: b3980a104afcd7a38bd3cd6a021bbc9642cdb4d9b883288f22146dc9be21501218ed7e1915110b909dae72db04bd180388983a78fb2ee243fe21e8abbdeb3831
7
+ data.tar.gz: fcb8afa4825ca82ba2d4350fdbcd23ff2324e02bf68a48ef7a66c49ef407dcbc71eee43d129725362e413695b64626f0a757bf98d4a674e6ef4af8649c854fad
data/README.md CHANGED
@@ -51,40 +51,35 @@ one has both a destructive and a nondestructive version):
51
51
 
52
52
  ```rb
53
53
  # Adjust an image so that its orientation is suitable for viewing.
54
- auto_orient(file)
55
- auto_orient!(file)
54
+ auto_orient[!](file)
56
55
 
57
56
  # Converts file to the specified format.
58
- convert(file, format)
59
- convert!(file, format)
57
+ convert[!](file, format)
60
58
 
61
59
  # Crop image to the defined area.
62
- crop(file, width, height, x_offset, y_offset, gravity: "NorthWest")
63
- crop!(file, width, height, x_offset, y_offset, gravity: "NorthWest")
60
+ crop[!](file, width, height, x_offset, y_offset, gravity: "NorthWest")
64
61
 
65
62
  # Resizes image to fit the specified dimensions (shrinks if larger, enlarges if
66
63
  # smaller, but keeps the aspect ratio).
67
- resize_to_fit(file, width, height)
68
- resize_to_fit!(file, width, height)
64
+ resize_to_fit[!](file, width, height)
69
65
 
70
66
  # Resizes image in limit of the specified dimensions (shrinks if larger, keeps
71
67
  # if smaller, but keeps the aspect ratio).
72
- resize_to_limit(file, width, height)
73
- resize_to_limit!(file, width, height)
68
+ resize_to_limit[!](file, width, height)
74
69
 
75
70
  # Resizes image to fill the specified dimensions (shrinks if larger,
76
71
  # enlarges if smaller, crops the longer side).
77
- resize_to_fill(file, width, height, gravity: "Center")
78
- resize_to_fill!(file, width, height, gravity: "Center")
72
+ resize_to_fill[!](file, width, height, gravity: "Center")
79
73
 
80
74
  # Resizes image to the specified dimensions and pads missing space (shrinks if
81
75
  # larger, enlarges if smaller, fills the shorter side with specified color).
82
- resize_and_pad(file, width, height, background: "transparent", gravity: "Center")
83
- resize_and_pad!(file, width, height, background: "transparent", gravity: "Center")
76
+ resize_and_pad[!](file, width, height, background: "transparent", gravity: "Center")
84
77
 
85
78
  # Resamples the image to a different resolution
86
- resample(file, horizontal, vertical)
87
- resample!(file, horizontal, vertical)
79
+ resample[!](file, horizontal, vertical)
80
+
81
+ # Returns true if the given image is corrupted
82
+ currupted?(file)
88
83
  ```
89
84
 
90
85
  If you want to do custom MiniMagick processing, each of the above optionally
@@ -160,7 +160,7 @@ module ImageProcessing
160
160
  # The resulting image will always be the same pixel size as the source with
161
161
  # an adjusted resolution dimensions.
162
162
  #
163
- # @param [MiniMagick::Image] img the image to convert
163
+ # @param [MiniMagick::Image] image the image to convert
164
164
  # @param [#to_s] width the dpi width
165
165
  # @param [#to_s] height the dpi height
166
166
  # @yield [MiniMagick::Tool::Mogrify, MiniMagick::Tool::Convert]
@@ -197,6 +197,21 @@ module ImageProcessing
197
197
  end
198
198
  nondestructive_alias :crop, :crop!
199
199
 
200
+ # Returns whether the image is corrupt.
201
+ #
202
+ # @param [File] image
203
+ # @return [Boolean]
204
+ def corrupted?(image)
205
+ ::MiniMagick::Tool::Identify.new do |identify|
206
+ identify.verbose
207
+ identify.regard_warnings
208
+ identify << image.path
209
+ end
210
+ false
211
+ rescue ::MiniMagick::Error
212
+ true
213
+ end
214
+
200
215
  # Convert an image into a MiniMagick::Image for the duration of the block,
201
216
  # and at the end return a File object.
202
217
  def with_minimagick(image)
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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: 0.3.0
4
+ version: 0.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: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest