image_processing 0.2.5 → 0.3.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: f50a933d3b59293412c8f598a646d4db0a756f6c
4
- data.tar.gz: 778e9010cc777117535ad0b229f84e27a2d05ce6
3
+ metadata.gz: af4532e0d6a06a00ac95a2c5f7190e4df6a4e891
4
+ data.tar.gz: 3a639bcbaa104a55a5d2387d4c4cfdeaaf5149ae
5
5
  SHA512:
6
- metadata.gz: 2b5d7eabf7b3e3a9733dc16e55c8e11a7cf49657b08b4313d09ce2e9481f8bc1ee5b424b067e9f2976219876569b7d3bfb121def6a5d6ffb2c0a78201e4dc140
7
- data.tar.gz: e51e778aff0a128b0bff398a4e79ec6cfc438091f7a3dee5c5afd927f41f1d55b721642ed113ebb9068b9deef6e756f0ec1ca944f55a9d2472d32726dc384e22
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
- This methods were extracted from Refile, and were made generic so that they can
7
- be used in any project. The goal is to have a centralized place where image
8
- processing helper methods are maintained, instead of CarrierWave, Dragonfly and
9
- Refile each having their own.
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
@@ -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
- spec.authors = ["Janko Marohnić"]
7
- spec.email = ["janko.marohnic@gmail.com"]
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)
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.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.2.5
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-24 00:00:00.000000000 Z
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
  - - ">="