image_processing 0.4.1 → 0.4.2
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 +4 -4
- data/README.md +18 -4
- data/lib/image_processing/mini_magick.rb +3 -3
- data/lib/image_processing/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac7f960131ea7d37acd2b0ceb8d4348e390cf12b
|
4
|
+
data.tar.gz: 87066472d1db007887ad332b321edb6699714725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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") #
|
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
|
-
|
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)
|
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
|
-
|
230
|
-
tempfile = Tempfile.new(
|
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
|
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.
|
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:
|
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.
|
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.
|