image_processing 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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: ffdeedc6dde0dbff761a5185ebbc0316ab9d70bd
4
- data.tar.gz: 42409b4d185f80c1462ee7aebe46e89daf2141ae
3
+ metadata.gz: 68f6d4b9e19542234865363bc7191ce501845e17
4
+ data.tar.gz: f71a5a4156182b2998e699d5d98f71ec03abca59
5
5
  SHA512:
6
- metadata.gz: 5da67c6c7794556ae3976acb86aaffe91f4fda1ae0363c2a179ce68d1a89b58bcc9c3b952d65d3dd9ca62c800a710b3e993b1e65da4ada0283541b250971f232
7
- data.tar.gz: 1c870e3254d44fea11e201a602df454bcb0201f9f0c668d18b551a838f9b720ee19da90ba043bd2a55f641bcb1664e0b197c2556ed0dba90080695a22503e9ca
6
+ metadata.gz: a410c6436c2f8a89d7b32298bd9dbb4e98a344a291a0d7282f35485bbe1139c31a5f834807b4ff872bf273e179ca9420c4a243f0da70fa8eeaa504573e3ef398
7
+ data.tar.gz: 4c2cb93dd82c915b1dcd7507e928f37d86db467ab908324006e7d7876b6e20a10b85afac0a732b0eba77767f9fd443fbf4497bd6dbacfcf746f41be091b52370
data/README.md CHANGED
@@ -12,6 +12,7 @@ Refile each having their own.
12
12
 
13
13
  ```ruby
14
14
  gem 'image_processing'
15
+ gem 'mini_magick', '>= 4.3.5'
15
16
  ```
16
17
 
17
18
  ## Usage
@@ -43,32 +44,64 @@ image = File.open("path/to/image.jpg")
43
44
  ImageProcessing::MiniMagick.resize_to_fit(image, 400, 400)
44
45
  ```
45
46
 
46
- The following is the list of helper methods that ImageProcessing provides:
47
+ The following is the list of helper methods that ImageProcessing provides (each
48
+ one has both a destructive and a nondestructive version):
47
49
 
48
50
  ```rb
51
+ # Adjust an image so that its orientation is suitable for viewing
52
+ auto_orient(file)
53
+ auto_orient!(file)
54
+
49
55
  # Converts file to the specified format.
50
- convert(file, format) # nondestructive
51
- convert!(file, format) # destructive
56
+ convert(file, format)
57
+ convert!(file, format)
52
58
 
53
59
  # Resizes image to fit the specified dimensions (shrinks if larger, enlarges if
54
60
  # smaller, but keeps the aspect ratio).
55
- resize_to_fit(file, width, height) # nondestructive
56
- resize_to_fit!(file, width, height) # destructive
61
+ resize_to_fit(file, width, height)
62
+ resize_to_fit!(file, width, height)
57
63
 
58
64
  # Resizes image in limit of the specified dimensions (shrinks if larger, keeps
59
65
  # if smaller, but keeps the aspect ratio).
60
- resize_to_limit(file, width, height) # nondestructive
61
- resize_to_limit!(file, width, height) # destructive
66
+ resize_to_limit(file, width, height)
67
+ resize_to_limit!(file, width, height)
62
68
 
63
69
  # Resizes image to fill the specified dimensions (shrinks if larger,
64
70
  # enlarges if smaller, crops the longer side).
65
- resize_to_fill(file, width, height, gravity: "Center") # nondestructive
66
- resize_to_fill!(file, width, height, gravity: "Center") # destructive
71
+ resize_to_fill(file, width, height, gravity: "Center")
72
+ resize_to_fill!(file, width, height, gravity: "Center")
67
73
 
68
74
  # Resizes image to the specified dimensions and pads missing space (shrinks if
69
75
  # larger, enlarges if smaller, fills the shorter side with specified color).
70
- resize_and_pad(file, width, height, background: "transparent", gravity: "Center") # nondestructive
71
- resize_and_pad!(file, width, height, background: "transparent", gravity: "Center") # destructive
76
+ resize_and_pad(file, width, height, background: "transparent", gravity: "Center")
77
+ resize_and_pad!(file, width, height, background: "transparent", gravity: "Center")
78
+
79
+ # Resamples the image to a different resolution
80
+ resample(file, horizontal, vertical)
81
+ resample!(file, horizontal, vertical)
82
+ ```
83
+
84
+ If you want to do custom MiniMagick processing, each of the above optionally
85
+ yields an instance of `MiniMagick::Tool`, so you can use it for additional
86
+ processing:
87
+
88
+ ```rb
89
+ convert(file, "png") do |cmd|
90
+ cmd.background("none")
91
+ end
92
+ ```
93
+
94
+ There is also a helper method for doing MiniMagick processing directly:
95
+
96
+ ```rb
97
+ processed = with_minimagick(file) do |image|
98
+ image #=> #<MiniMagick::Image ...>
99
+ image.combine_options do |cmd|
100
+ # ...
101
+ end
102
+ end
103
+
104
+ processed #=> #<File ...>
72
105
  ```
73
106
 
74
107
  ## Contributing
@@ -12,6 +12,7 @@ module ImageProcessing
12
12
  define_method(name) do |image, *args, &block|
13
13
  send(original, _copy_to_tempfile(image), *args, &block)
14
14
  end
15
+ module_function name
15
16
  end
16
17
 
17
18
  module_function
@@ -180,7 +181,9 @@ module ImageProcessing
180
181
  def with_minimagick(image)
181
182
  image = ::MiniMagick::Image.new(image.path, image)
182
183
  yield image
183
- image.instance_variable_get("@tempfile")
184
+ tempfile = image.instance_variable_get("@tempfile")
185
+ tempfile.open if tempfile.is_a?(Tempfile) # for aws-sdk
186
+ tempfile
184
187
  end
185
188
 
186
189
  # Creates a copy of the file and stores it into a Tempfile. Works for any
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-04 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest