image_processing 0.2.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d685d2233ad9b0da42966e273cc5a453215eb82a
4
- data.tar.gz: 18ce0a061ba6eeff0501c311aa9f217404c25371
3
+ metadata.gz: ffdeedc6dde0dbff761a5185ebbc0316ab9d70bd
4
+ data.tar.gz: 42409b4d185f80c1462ee7aebe46e89daf2141ae
5
5
  SHA512:
6
- metadata.gz: 8859c7bcf11803b4e41b8eb03f04fc30ddf65ffd4756c4c4d76907189fb7a7c5fb9bb4f1b6287b34ce21cd07b7c0edd566fb9ec14b30d128bdea910c6f31c802
7
- data.tar.gz: 649891929efd850e926f6f30487dfca66c44e12f614dff1b47fa0e4191e368880f331ee88634cebe381aad90fa73824eca8afaf0c432f1a1adc53d651235abd6
6
+ metadata.gz: 5da67c6c7794556ae3976acb86aaffe91f4fda1ae0363c2a179ce68d1a89b58bcc9c3b952d65d3dd9ca62c800a710b3e993b1e65da4ada0283541b250971f232
7
+ data.tar.gz: 1c870e3254d44fea11e201a602df454bcb0201f9f0c668d18b551a838f9b720ee19da90ba043bd2a55f641bcb1664e0b197c2556ed0dba90080695a22503e9ca
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # ImageProcessing
2
2
 
3
3
  Provides higher-level helper methods for image processing in Ruby using
4
- ImageMagick. This methods are extracted from CarrierWave and Refile, and
5
- can be reused in any project.
4
+ ImageMagick.
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
10
 
7
11
  ## Installation
8
12
 
@@ -24,12 +24,28 @@ module ImageProcessing
24
24
  # @yield [MiniMagick::Tool::Mogrify, MiniMagick::Tool::Convert]
25
25
  # @return [File, Tempfile]
26
26
  def convert!(image, format, &block)
27
- _with_minimagick(image) do |img|
27
+ with_minimagick(image) do |img|
28
28
  img.format(format.downcase, nil, &block)
29
29
  end
30
30
  end
31
31
  nondestructive_alias :convert, :convert!
32
32
 
33
+ # Adjusts the image so that its orientation is suitable for viewing.
34
+ #
35
+ # @see http://www.imagemagick.org/script/command-line-options.php#auto-orient
36
+ # @param [MiniMagick::Image] image the image to convert
37
+ # @yield [MiniMagick::Tool::Mogrify, MiniMagick::Tool::Convert]
38
+ # @return [File, Tempfile]
39
+ def auto_orient!(image)
40
+ with_minimagick(image) do |img|
41
+ img.combine_options do |cmd|
42
+ yield cmd if block_given?
43
+ cmd.auto_orient
44
+ end
45
+ end
46
+ end
47
+ nondestructive_alias :auto_orient, :auto_orient!
48
+
33
49
  # Resize the image to fit within the specified dimensions while retaining
34
50
  # the original aspect ratio. Will only resize the image if it is larger
35
51
  # than the specified dimensions. The resulting image may be shorter or
@@ -42,7 +58,7 @@ module ImageProcessing
42
58
  # @yield [MiniMagick::Tool::Mogrify, MiniMagick::Tool::Convert]
43
59
  # @return [File, Tempfile]
44
60
  def resize_to_limit!(image, width, height)
45
- _with_minimagick(image) do |img|
61
+ with_minimagick(image) do |img|
46
62
  img.combine_options do |cmd|
47
63
  yield cmd if block_given?
48
64
  cmd.resize "#{width}x#{height}>"
@@ -62,7 +78,7 @@ module ImageProcessing
62
78
  # @yield [MiniMagick::Tool::Mogrify, MiniMagick::Tool::Convert]
63
79
  # @return [File, Tempfile]
64
80
  def resize_to_fit!(image, width, height)
65
- _with_minimagick(image) do |img|
81
+ with_minimagick(image) do |img|
66
82
  img.combine_options do |cmd|
67
83
  yield cmd if block_given?
68
84
  cmd.resize "#{width}x#{height}"
@@ -88,7 +104,7 @@ module ImageProcessing
88
104
  # @return [File, Tempfile]
89
105
  # @see http://www.imagemagick.org/script/command-line-options.php#gravity
90
106
  def resize_to_fill!(image, width, height, gravity: "Center")
91
- _with_minimagick(image) do |img|
107
+ with_minimagick(image) do |img|
92
108
  img.combine_options do |cmd|
93
109
  yield cmd if block_given?
94
110
  cmd.resize "#{width}x#{height}^"
@@ -121,7 +137,7 @@ module ImageProcessing
121
137
  # @see http://www.imagemagick.org/script/color.php
122
138
  # @see http://www.imagemagick.org/script/command-line-options.php#gravity
123
139
  def resize_and_pad!(image, width, height, background: "transparent", gravity: "Center")
124
- _with_minimagick(image) do |img|
140
+ with_minimagick(image) do |img|
125
141
  img.combine_options do |cmd|
126
142
  yield cmd if block_given?
127
143
  cmd.resize "#{width}x#{height}"
@@ -150,7 +166,7 @@ module ImageProcessing
150
166
  # @return [File, Tempfile]
151
167
  # @see http://www.imagemagick.org/script/command-line-options.php#resample
152
168
  def resample!(image, width, height)
153
- _with_minimagick(image) do |img|
169
+ with_minimagick(image) do |img|
154
170
  img.combine_options do |cmd|
155
171
  yield cmd if block_given?
156
172
  cmd.resample "#{width}x#{height}"
@@ -161,7 +177,7 @@ module ImageProcessing
161
177
 
162
178
  # Convert an image into a MiniMagick::Image for the duration of the block,
163
179
  # and at the end return a File object.
164
- def _with_minimagick(image)
180
+ def with_minimagick(image)
165
181
  image = ::MiniMagick::Image.new(image.path, image)
166
182
  yield image
167
183
  image.instance_variable_get("@tempfile")
@@ -1,3 +1,3 @@
1
1
  module ImageProcessing
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.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.2.1
4
+ version: 0.2.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: 2015-10-03 00:00:00.000000000 Z
11
+ date: 2015-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest