image_processing 0.2.5 → 0.3.0
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 +13 -5
- data/image_processing.gemspec +4 -2
- data/lib/image_processing/mini_magick.rb +21 -0
- 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: af4532e0d6a06a00ac95a2c5f7190e4df6a4e891
|
4
|
+
data.tar.gz: 3a639bcbaa104a55a5d2387d4c4cfdeaaf5149ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 279b62385e8c5b7edb4baa3c749063dd8e40a03ceaee7216f6a9db3377287337c63b301935f95a3ca715b30f52fadff642484e42100a60acd7c5c1bff79a075e
|
7
|
+
data.tar.gz: 876bc51156893cd604d17ab8b1d2954f92136fea590b93e809575f44ba98ef6c1509bb6657ba2f6797ce32816aa7da0201710a5c620b56e64af1a61134bfbae4
|
data/README.md
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
Provides higher-level helper methods for image processing in Ruby using
|
4
4
|
ImageMagick.
|
5
5
|
|
6
|
-
|
7
|
-
be used in any project. The goal is to have a
|
8
|
-
|
9
|
-
Refile each
|
6
|
+
These methods were extracted from [refile-mini_magick], and were made generic so
|
7
|
+
that they can be used in any project. The goal of image_processing is to have a
|
8
|
+
centralized place where helper methods for image processing are maintained,
|
9
|
+
instead of CarrierWave, Dragonfly and Refile each implementing their own.
|
10
|
+
|
11
|
+
It's been tested with MRI 2.x, JRuby and Rubinius.
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
@@ -48,7 +50,7 @@ The following is the list of helper methods that ImageProcessing provides (each
|
|
48
50
|
one has both a destructive and a nondestructive version):
|
49
51
|
|
50
52
|
```rb
|
51
|
-
# Adjust an image so that its orientation is suitable for viewing
|
53
|
+
# Adjust an image so that its orientation is suitable for viewing.
|
52
54
|
auto_orient(file)
|
53
55
|
auto_orient!(file)
|
54
56
|
|
@@ -56,6 +58,10 @@ auto_orient!(file)
|
|
56
58
|
convert(file, format)
|
57
59
|
convert!(file, format)
|
58
60
|
|
61
|
+
# 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")
|
64
|
+
|
59
65
|
# Resizes image to fit the specified dimensions (shrinks if larger, enlarges if
|
60
66
|
# smaller, but keeps the aspect ratio).
|
61
67
|
resize_to_fit(file, width, height)
|
@@ -122,3 +128,5 @@ $ rake test
|
|
122
128
|
## License
|
123
129
|
|
124
130
|
[MIT](LICENSE.txt)
|
131
|
+
|
132
|
+
[refile-mini_magick]: https://github.com/refile/refile-mini_magick
|
data/image_processing.gemspec
CHANGED
@@ -3,12 +3,14 @@ require File.expand_path('../lib/image_processing/version', __FILE__)
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "image_processing"
|
5
5
|
spec.version = ImageProcessing::VERSION
|
6
|
-
|
7
|
-
spec.
|
6
|
+
|
7
|
+
spec.required_ruby_version = ">= 2.0"
|
8
8
|
|
9
9
|
spec.summary = "Set of higher-level helper methods for image processing."
|
10
10
|
spec.description = "Set of higher-level helper methods for image processing."
|
11
11
|
spec.homepage = "https://github.com/janko-m/image_processing"
|
12
|
+
spec.authors = ["Janko Marohnić"]
|
13
|
+
spec.email = ["janko.marohnic@gmail.com"]
|
12
14
|
spec.license = "MIT"
|
13
15
|
|
14
16
|
spec.files = Dir["README.md", "LICENSE.txt", "lib/**/*", "image_processing.gemspec"]
|
@@ -176,6 +176,27 @@ module ImageProcessing
|
|
176
176
|
end
|
177
177
|
nondestructive_alias :resample, :resample!
|
178
178
|
|
179
|
+
# Crops the image to be the defined area.
|
180
|
+
#
|
181
|
+
# @param [#to_s] width the width of the cropped image
|
182
|
+
# @param [#to_s] height the height of the cropped image
|
183
|
+
# @param [#to_s] x_offset the x coordinate where to start cropping
|
184
|
+
# @param [#to_s] y_offset the y coordinate where to start cropping
|
185
|
+
# @param [string] gravity which part of the image to focus on
|
186
|
+
# @yield [MiniMagick::Tool::Mogrify, MiniMagick::Tool::Convert]
|
187
|
+
# @return [File, Tempfile]
|
188
|
+
# @see http://www.imagemagick.org/script/command-line-options.php#crop
|
189
|
+
def crop!(image, width, height, x_offset = 0, y_offset = 0, gravity: "NorthWest")
|
190
|
+
with_minimagick(image) do |img|
|
191
|
+
img.combine_options do |cmd|
|
192
|
+
yield cmd if block_given?
|
193
|
+
cmd.gravity gravity
|
194
|
+
cmd.crop "#{width}x#{height}+#{x_offset}+#{y_offset}"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
nondestructive_alias :crop, :crop!
|
199
|
+
|
179
200
|
# Convert an image into a MiniMagick::Image for the duration of the block,
|
180
201
|
# and at the end return a File object.
|
181
202
|
def with_minimagick(image)
|
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
|
+
version: 0.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: 2016-03
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '0'
|
107
|
+
version: '2.0'
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - ">="
|