imanip 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/lib/imanip/imanip_magick.rb +21 -5
- data/lib/imanip/version.rb +1 -1
- data/test/test_imanip_magick.rb +8 -0
- metadata +14 -5
data/History.txt
CHANGED
data/lib/imanip/imanip_magick.rb
CHANGED
@@ -7,29 +7,46 @@ module Imanip
|
|
7
7
|
attr_accessor :execute_path
|
8
8
|
end
|
9
9
|
|
10
|
-
attr_reader :width, :height, :format
|
10
|
+
attr_reader :width, :height, :format, :image_path
|
11
11
|
|
12
12
|
def initialize(path)
|
13
13
|
@image_path = path
|
14
14
|
identify
|
15
15
|
end
|
16
|
+
|
17
|
+
|
16
18
|
alias_method :columns, :width
|
17
19
|
alias_method :rows, :height
|
18
20
|
|
21
|
+
# Return the dimensions of the image as an array of Fixnums [width,height]
|
19
22
|
def dimensions
|
20
23
|
[width,height]
|
21
24
|
end
|
22
|
-
|
25
|
+
|
26
|
+
# Returns true if the image is taller then it is long
|
23
27
|
def portrait?
|
24
28
|
width < height
|
25
29
|
end
|
26
30
|
|
31
|
+
# Returns true if the image is longer then it is tall
|
27
32
|
def landscape?
|
28
33
|
width > height
|
29
34
|
end
|
30
35
|
|
36
|
+
# Returns true if width == height
|
37
|
+
def square?
|
38
|
+
width == height
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns symbol of the images orientation. Can be :landscape, :portrait, or :square
|
31
42
|
def orientation
|
32
|
-
landscape?
|
43
|
+
if landscape?
|
44
|
+
:landscape
|
45
|
+
elsif portrait?
|
46
|
+
:portrait
|
47
|
+
else
|
48
|
+
:square
|
49
|
+
end
|
33
50
|
end
|
34
51
|
|
35
52
|
def crop(to_file, options = {})
|
@@ -86,7 +103,6 @@ module Imanip
|
|
86
103
|
|
87
104
|
def convert(to_file,options = {})
|
88
105
|
command = "#{execute_path}convert #{@image_path} #{options_to_string(options)} #{to_file}"
|
89
|
-
# puts command
|
90
106
|
response = execute(command)
|
91
107
|
# catch errors in response
|
92
108
|
possible_errors = [
|
@@ -96,7 +112,7 @@ module Imanip
|
|
96
112
|
raise(CouldNotConvertError, response + " when " + command) if response =~ error
|
97
113
|
end
|
98
114
|
# assert that the new file exits
|
99
|
-
File.readable?(to_file) ? to_file : raise(CouldNotConvertError)
|
115
|
+
File.readable?(to_file) ? Imanip::Image.new(to_file, :magick) : raise(CouldNotConvertError)
|
100
116
|
end
|
101
117
|
|
102
118
|
private
|
data/lib/imanip/version.rb
CHANGED
data/test/test_imanip_magick.rb
CHANGED
@@ -82,6 +82,14 @@ class ImanipMagickTest < Test::Unit::TestCase
|
|
82
82
|
assert_equal dimensions, @new_image.dimensions
|
83
83
|
end
|
84
84
|
|
85
|
+
def test_crop_resize_should_return_a_imanip_image
|
86
|
+
dimensions = [100,100]
|
87
|
+
@new_image = @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
|
88
|
+
assert @new_image.is_a?(Imanip::Image)
|
89
|
+
assert_equal dimensions, @new_image.dimensions
|
90
|
+
end
|
91
|
+
|
92
|
+
|
85
93
|
|
86
94
|
def test_should_throw_errors_if_image_could_not_be_converted
|
87
95
|
assert_raise(Imanip::CouldNotConvertError) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imanip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Quint
|
@@ -9,10 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-27 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.7.0
|
24
|
+
version:
|
16
25
|
description: Super-quick image resizing using the ImageMagick command line tools
|
17
26
|
email:
|
18
27
|
- aaron@quirkey.com
|
@@ -68,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
77
|
requirements: []
|
69
78
|
|
70
79
|
rubyforge_project: quirkey
|
71
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.2.0
|
72
81
|
signing_key:
|
73
82
|
specification_version: 2
|
74
83
|
summary: Super-quick image resizing using the ImageMagick command line tools
|