image_processing 0.4.1 → 0.4.2

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: 7db56488f4243b78680a4b83a1b19bdd9b35dc15
4
- data.tar.gz: 8c8019e70d1fafd475b66ae604863970fd4b29cc
3
+ metadata.gz: ac7f960131ea7d37acd2b0ceb8d4348e390cf12b
4
+ data.tar.gz: 87066472d1db007887ad332b321edb6699714725
5
5
  SHA512:
6
- metadata.gz: b354605b303b31e6b24616c4af41c7bccde44de28028bf7fdac90a6814e394a940c1276ededd5d81a60c60af4515b3b51ff61543d6a90e7227435c1159fd8e9d
7
- data.tar.gz: 371b60fb65430e61045b211e8e69ab3349aaa398885391ffc0990bdd6e9a44e10db759db467afd5a2363f6f7b02b001e228625fe478a04bb9d7f433d34e139bc
6
+ metadata.gz: 43da9320417a0b03d33d25fc44b962d3e32d96da957c58ba82706c66190537337fd2039e75ab24b7a42ae1c90b3326f18e146d03bb447bfbb1ea63ff130dff7c
7
+ data.tar.gz: e1494df40868d17ed542979ac7c6bc8f3aaab6d5fa5a045f3a712b4bd13310e33bd0bbddf60e44f9ce70343956546053e9bd64fb70809932a04b157a6122d53c
data/README.md CHANGED
@@ -32,7 +32,7 @@ converted = convert(original, "png") # makes a converted copy
32
32
  converted #=> #<Tempfile:/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/mini_magick20151003-23030-9e1vjz.png (closed)>
33
33
  File.exist?(original.path) #=> true
34
34
 
35
- converted = convert!(original, "png") # destructively converts the file
35
+ converted = convert!(original, "png") # converts the file in-place
36
36
  converted #=> #<Tempfile:/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/mini_magick20151003-23030-9e1vjz.png (closed)>
37
37
  File.exist?(original.path) #=> false
38
38
  ```
@@ -46,6 +46,8 @@ image = File.open("path/to/image.jpg")
46
46
  ImageProcessing::MiniMagick.resize_to_fit(image, 400, 400)
47
47
  ```
48
48
 
49
+ ### Methods
50
+
49
51
  The following is the list of helper methods that ImageProcessing provides (each
50
52
  one has both a destructive and a nondestructive version):
51
53
 
@@ -53,8 +55,9 @@ one has both a destructive and a nondestructive version):
53
55
  # Adjust an image so that its orientation is suitable for viewing.
54
56
  auto_orient[!](file)
55
57
 
56
- # Converts file to the specified format.
57
- convert[!](file, format)
58
+ # Converts file to the specified format, and you can specify to convert only a
59
+ # certain page for multilayered formats.
60
+ convert[!](file, format, page = nil)
58
61
 
59
62
  # Crop image to the defined area.
60
63
  crop[!](file, width, height, x_offset, y_offset, gravity: "NorthWest")
@@ -82,6 +85,16 @@ resample[!](file, horizontal, vertical)
82
85
  currupted?(file)
83
86
  ```
84
87
 
88
+ For `#resize_to_limit[!]` and `#resize_to_fit[!]` you can don't have to specify
89
+ both dimensions:
90
+
91
+ ```rb
92
+ resize_to_limit(image, 300, nil)
93
+ resize_to_fit(image, nil, 500)
94
+ ```
95
+
96
+ ### Dropping to MiniMagick
97
+
85
98
  If you want to do custom MiniMagick processing, each of the above optionally
86
99
  yields an instance of `MiniMagick::Tool`, so you can use it for additional
87
100
  processing:
@@ -92,7 +105,8 @@ convert(file, "png") do |cmd|
92
105
  end
93
106
  ```
94
107
 
95
- There is also a helper method for doing MiniMagick processing directly:
108
+ There is also a helper method for doing MiniMagick processing directly (though
109
+ note that this will process the image in-place!):
96
110
 
97
111
  ```rb
98
112
  processed = with_minimagick(file) do |image|
@@ -219,15 +219,15 @@ module ImageProcessing
219
219
  image = ::MiniMagick::Image.new(image.path, image)
220
220
  yield image
221
221
  tempfile = image.instance_variable_get("@tempfile")
222
- tempfile.open if tempfile.is_a?(Tempfile) # for aws-sdk
222
+ tempfile.open if tempfile.is_a?(Tempfile)
223
223
  tempfile
224
224
  end
225
225
 
226
226
  # Creates a copy of the file and stores it into a Tempfile. Works for any
227
227
  # IO object that responds to `#read(length = nil, outbuf = nil)`.
228
228
  def _copy_to_tempfile(file)
229
- args = [File.basename(file.path, ".*"), File.extname(file.path)] if file.respond_to?(:path)
230
- tempfile = Tempfile.new(args || "image", binmode: true)
229
+ extension = File.extname(file.path) if file.respond_to?(:path)
230
+ tempfile = Tempfile.new(["mini_magick", extension], binmode: true)
231
231
  IO.copy_stream(file, tempfile.path)
232
232
  file.rewind
233
233
  tempfile
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
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.4.1
4
+ version: 0.4.2
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-09-08 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.5.1
115
+ rubygems_version: 2.6.11
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Set of higher-level helper methods for image processing.