quirkey-imanip 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,22 @@
1
+ == 0.1.4 2008-10-16
2
+
3
+ * minor enhancements
4
+ * Added Image#ratio
5
+ * Crop resize is way better based on ratios
6
+
7
+ == 0.1.2 2008-08-27
8
+
9
+ * minor enhancements
10
+ * Magick#convert now returns an imanip image
11
+ * Image#square?
12
+ * some inline documentation
13
+
14
+ == 0.1.1 2008-06-13
15
+
16
+ * 1 minor enhancement:
17
+ * Added rows and columns alias for width and height
18
+
19
+ == 0.1.0 2008-06-13
20
+
21
+ * 1 major enhancement:
22
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Aaron Quint, Quirkey NYC, LLC.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,19 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ init.rb
9
+ install.rb
10
+ lib/imanip.rb
11
+ lib/imanip/errors.rb
12
+ lib/imanip/image.rb
13
+ lib/imanip/imanip_magick.rb
14
+ lib/imanip/version.rb
15
+ test/landscape_test.jpg
16
+ test/portrait_test.jpg
17
+ test/test_helper.rb
18
+ test/test_imanip_magick.rb
19
+ uninstall.rb
data/README.txt ADDED
@@ -0,0 +1,120 @@
1
+ = imanip
2
+
3
+ http://quirkey.sourceforge.com/imanip/
4
+ http://github.com/quirkey/imanip/
5
+
6
+ == DESCRIPTION:
7
+
8
+ Super-quick image resizing using the ImageMagick command line tools
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ - Simple API
13
+ - 0% Overhead
14
+ - Uses the ImageMagick command line tools (convert, identify)
15
+
16
+ NOTE:
17
+ The API is going to be changing a lot as I try to lock down something really useful. As a quick git-er-done type doodad
18
+ it works really well, and I'm already using it on some very high volume production sites.
19
+
20
+ == SYNOPSIS:
21
+
22
+
23
+ First things, first, Tell me where you keep them:
24
+
25
+
26
+ # Rails: production|development|etc.rb
27
+ # or somewhere that gets loaded before you initialize
28
+
29
+ Imanip::Interface::Magick.execute_path = '/path/to/your/bins/' # eg /usr/local/bin/
30
+
31
+
32
+ With an image file at /dir/image.jpg
33
+
34
+ image = Imanip::Image.new('/dir/image.jpg')
35
+
36
+ This will run identify on the image and make sure its convert-able. If it cant read or interpret it it will raise an Imanip::NotAnImageError.
37
+
38
+ Once you have the image you can check some properties/attributes
39
+
40
+ image.width #=> 410 (Fixnum)
41
+ image.height #=> 100 (Fixnum)
42
+ image.format #=> JPEG (String)
43
+
44
+ There are also some helpers to do some rule based cropping.
45
+
46
+ image.portrait? #=> false
47
+ image.landscape? #=> true
48
+ image.orientation #=> :landscape
49
+
50
+ After that you can resize and whatever
51
+
52
+ image.resize('outputfile.jpg', :dimensions => [200,100])
53
+
54
+ I like crop_resize better. It crops AND resizes so you get an image of the exact pixel dimensions you desire.
55
+
56
+ image.crop_resize('/file/to/output.jpg', :width => 50, :height => 50) #=> output file is an exact 50x50 image
57
+
58
+ You might also want to catch errors, because they will inevitably happen. Possible Errors
59
+
60
+ Imanip::Error # the root, the root, the root is on fire
61
+ Imanip::NotAnImageError # Descends from above, thrown during Imanip#Image.new
62
+ Imanip::CouldNotConvertError # Also from above, thrown if theres an issue with #resize or #crop_resize (options, etc.)
63
+
64
+ More examples coming soon.
65
+
66
+ == REQUIREMENTS:
67
+
68
+ You need ImageMagick. Really any version will do, but I am developing with ImageMagick 6.3.3.
69
+
70
+ http://www.imagemagick.org/script/download.php
71
+
72
+
73
+ == INSTALL:
74
+
75
+ First, install ImageMagick:
76
+ http://www.imagemagick.org/script/download.php
77
+
78
+ Make sure you get the command line tools:
79
+
80
+ $ which 'convert'
81
+
82
+ Imanip works as a gem or a plugin for Rails.
83
+
84
+ As a gem:
85
+
86
+ $ sudo gem install imanip
87
+
88
+ In Rails/environment.rb
89
+ config.gem 'imanip'
90
+
91
+ Or you can get the ABSOLUTE latest from github:
92
+
93
+ $ sudo gem install quirkey-imanip -s http://gems.github.com
94
+
95
+ To install as a plugin (you need git):
96
+
97
+ $ git clone git://github.com/quirkey/imanip.git vendor/plugins/imanip
98
+
99
+ == LICENSE:
100
+
101
+ Copyright (c) 2008 Aaron Quint, Quirkey
102
+
103
+ Permission is hereby granted, free of charge, to any person obtaining
104
+ a copy of this software and associated documentation files (the
105
+ 'Software'), to deal in the Software without restriction, including
106
+ without limitation the rights to use, copy, modify, merge, publish,
107
+ distribute, sublicense, and/or sell copies of the Software, and to
108
+ permit persons to whom the Software is furnished to do so, subject to
109
+ the following conditions:
110
+
111
+ The above copyright notice and this permission notice shall be
112
+ included in all copies or substantial portions of the Software.
113
+
114
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
115
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
116
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
117
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
118
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
119
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
120
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'imanip/version'
2
+
3
+ AUTHOR = 'Aaron Quint' # can also be an array of Authors
4
+ EMAIL = 'aaron@quirkey.com'
5
+ DESCRIPTION = "Super-quick image resizing using the ImageMagick command line tools"
6
+ GEM_NAME = 'imanip' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'quirkey' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = Imanip::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'imanip documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require File.expand_path(File.dirname(__FILE__)) + "/lib/imanip"
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
data/lib/imanip.rb ADDED
@@ -0,0 +1,3 @@
1
+ %w{image imanip_magick errors}.each do |lib|
2
+ require File.expand_path(File.dirname(__FILE__)) + "/imanip/#{lib}"
3
+ end
@@ -0,0 +1,5 @@
1
+ module Imanip
2
+ class ImanipError < RuntimeError; end;
3
+ class NotAnImageError < ImanipError; end;
4
+ class CouldNotConvertError < ImanipError; end;
5
+ end
@@ -0,0 +1,19 @@
1
+ module Imanip
2
+ class Image
3
+
4
+ def initialize(path,interface = :magick)
5
+ @image_path = path
6
+ load_interface(interface)
7
+ end
8
+
9
+ private
10
+ def load_interface(interface)
11
+ @interface = Imanip::Interface.const_get("#{interface.to_s.capitalize}").new(@image_path)
12
+ end
13
+
14
+ def method_missing(method, *args)
15
+ @interface.send(method,*args)
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,165 @@
1
+ module Imanip
2
+ module Interface
3
+
4
+ class Magick
5
+ class << self
6
+ @execute_path = ''
7
+ attr_accessor :execute_path
8
+ end
9
+
10
+ attr_reader :width, :height, :format, :image_path
11
+
12
+ def initialize(path)
13
+ @image_path = path
14
+ identify
15
+ end
16
+
17
+
18
+ alias_method :columns, :width
19
+ alias_method :rows, :height
20
+
21
+ # Return the dimensions of the image as an array of Fixnums [width,height]
22
+ def dimensions
23
+ [width,height]
24
+ end
25
+
26
+ # Returns true if the image is taller then it is long
27
+ def portrait?
28
+ width < height
29
+ end
30
+
31
+ # Returns true if the image is longer then it is tall
32
+ def landscape?
33
+ width > height
34
+ end
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
42
+ def orientation
43
+ if landscape?
44
+ :landscape
45
+ elsif portrait?
46
+ :portrait
47
+ else
48
+ :square
49
+ end
50
+ end
51
+
52
+ def ratio
53
+ width.to_f / height.to_f
54
+ end
55
+
56
+ def crop(to_file, options = {})
57
+ @options = options
58
+ parse_size_options!
59
+ @options[:crop] = to_geometry_string(@geometry)
60
+ convert(to_file, options)
61
+ end
62
+
63
+ def resize(to_file, options = {})
64
+ @options = options
65
+ parse_size_options!
66
+ @options[:resize] = to_geometry_string(@geometry)
67
+ convert(to_file, @options)
68
+ end
69
+
70
+ def crop_resize(to_file, options = {})
71
+ @options = options.dup
72
+ parse_size_options!
73
+ crop_resize_string = ""
74
+ crop_width = @geometry[:width]
75
+ crop_height = @geometry[:height]
76
+ if !(crop_height.nil? || crop_width.nil?)
77
+ crop_ratio = crop_width.to_f / crop_height.to_f
78
+ if crop_ratio > ratio
79
+ crop_resize_string << "-resize #{to_geometry_string(:width => crop_width)}"
80
+ else
81
+ crop_resize_string << "-resize #{to_geometry_string(:height => crop_height)}"
82
+ end
83
+ else
84
+ crop_resize_string << "-resize #{to_geometry_string(:height => crop_height, :width => crop_width)}"
85
+ end
86
+ gravity = @options.delete(:gravity) || 'North'
87
+ crop_resize_string << " -gravity '#{gravity}'"
88
+ crop_resize_string << " -crop #{to_geometry_string(@geometry)}+0+0"
89
+ crop_resize_string << " #{options_to_string(@options)}"
90
+ convert(to_file,crop_resize_string)
91
+ end
92
+ alias :crop_resized :crop_resize
93
+
94
+ def identify(options = {})
95
+ response = execute("#{execute_path}identify #{options_to_string(options)} #{@image_path}")
96
+ matches = response.match(/(JPEG|PNG|GIF)\ (\d+)x(\d+)/)
97
+ raise NotAnImageError, "Could not identify the image #{@image_path} as an image: #{response}" if matches.nil?
98
+ @format = matches[1]
99
+ @width = matches[2].to_i
100
+ @height = matches[3].to_i
101
+ end
102
+
103
+ def convert(to_file,options = {})
104
+ command = "#{execute_path}convert #{@image_path} #{options_to_string(options)} #{to_file}"
105
+ response = execute(command)
106
+ # catch errors in response
107
+ possible_errors = [
108
+ /invalid argument/
109
+ ]
110
+ possible_errors.each do |error|
111
+ raise(CouldNotConvertError, response + " when " + command) if response =~ error
112
+ end
113
+ # assert that the new file exits
114
+ File.readable?(to_file) ? Imanip::Image.new(to_file, :magick) : raise(CouldNotConvertError)
115
+ end
116
+
117
+ private
118
+
119
+ def parse_size_options!
120
+ @geometry = {}
121
+ if @options[:geometry]
122
+ width, height = @options.delete(:geometry).split('x')
123
+ @geometry = {:width => width, :height => height}
124
+ end
125
+ if @options[:dimensions]
126
+ width, height = @options.delete(:dimensions)
127
+ @geometry = {:width => width, :height => height}
128
+ end
129
+ @geometry = {:width => @options.delete(:width), :height => @options.delete(:height) } if @options[:width] || @options[:height]
130
+ @geometry.collect {|d| d[1].to_i unless d.nil? }
131
+ end
132
+
133
+ def to_geometry_string(width_height)
134
+ # puts "width_height: #{width_height.inspect}"
135
+ geometry_string = case width_height
136
+ when Array
137
+ width_height.join("x")
138
+ when Hash
139
+ "#{width_height[:width]}x#{width_height[:height]}"
140
+ else
141
+ width_height.to_s
142
+ end
143
+ "'#{geometry_string}'"
144
+ end
145
+
146
+ def options_to_string(options)
147
+ return options if options.is_a?(String)
148
+ option_string = ""
149
+ options.each do |name,value|
150
+ option_string << "-#{name} #{value} "
151
+ end
152
+ option_string
153
+ end
154
+
155
+ def execute(command)
156
+ `#{command} 2>&1`
157
+ end
158
+
159
+ def execute_path
160
+ self.class.execute_path
161
+ end
162
+ end
163
+
164
+ end
165
+ end
@@ -0,0 +1,9 @@
1
+ module Imanip #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 4
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
Binary file
Binary file
@@ -0,0 +1,23 @@
1
+ require 'test/unit'
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/imanip'))
3
+
4
+ class Test::Unit::TestCase
5
+
6
+ protected
7
+ def current_path
8
+ File.expand_path(File.dirname(__FILE__))
9
+ end
10
+
11
+ def portrait_image_path
12
+ File.join(current_path,'portrait_test.jpg')
13
+ end
14
+
15
+ def landscape_image_path
16
+ File.join(current_path,'landscape_test.jpg')
17
+ end
18
+
19
+ def new_image_path
20
+ File.join(current_path, "new_file.jpg")
21
+ end
22
+
23
+ end
@@ -0,0 +1,125 @@
1
+ # require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
+
3
+ class ImanipMagickTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @portrait_image = new_imanip_image(portrait_image_path)
7
+ @landscape_image = new_imanip_image(landscape_image_path)
8
+ end
9
+
10
+ def teardown
11
+ File.unlink(new_image_path) if File.readable?(new_image_path)
12
+ end
13
+
14
+ def test_should_raise_error_if_not_an_image
15
+ assert_raise(Imanip::NotAnImageError) do
16
+ new_imanip_image(__FILE__)
17
+ end
18
+ end
19
+
20
+ def test_should_return_an_imanip_image
21
+ assert @portrait_image.is_a?(Imanip::Image)
22
+ end
23
+
24
+ def test_should_return_dimensions_as_array
25
+ dimensions = @portrait_image.dimensions
26
+ assert dimensions.is_a?(Array)
27
+ assert_equal [411,519], dimensions
28
+
29
+ dimensions = @landscape_image.dimensions
30
+ assert dimensions.is_a?(Array)
31
+ assert_equal [400,315], dimensions
32
+ end
33
+
34
+ def test_portrait_should_return_true_for_portrait_image
35
+ assert @portrait_image.portrait?
36
+ end
37
+
38
+ def test_portrait_should_return_false_for_landscape_image
39
+ assert !@landscape_image.portrait?
40
+ end
41
+
42
+ def test_landscape_should_return_true_for_landscape_image
43
+ assert @landscape_image.landscape?
44
+ end
45
+
46
+ def test_landscape_should_return_false_for_portrait_image
47
+ assert !@portrait_image.landscape?
48
+ end
49
+
50
+ def test_ratio_should_return_width_over_height
51
+ assert_equal(@landscape_image.width.to_f / @landscape_image.height.to_f, @landscape_image.ratio)
52
+ end
53
+
54
+ def test_resize_should_save_to_new_file
55
+ assert !File.readable?(new_image_path)
56
+ assert @portrait_image.resize(new_image_path, :width => 50)
57
+ assert File.readable?(new_image_path)
58
+ end
59
+
60
+ def test_resize_should_resize_image_to_new_image_at_dimensions
61
+ dimensions = [100,126]
62
+ assert @portrait_image.resize(new_image_path, :dimensions => dimensions)
63
+ @new_image = new_imanip_image(new_image_path)
64
+ assert_equal dimensions, @new_image.dimensions
65
+ end
66
+
67
+ def test_resize_should_resize_image_to_new_image_at_width
68
+ width = 100
69
+ assert @portrait_image.resize(new_image_path, :width => width)
70
+ @new_image = new_imanip_image(new_image_path)
71
+ assert_equal width, @new_image.width
72
+ assert_not_equal @portrait_image.height, @new_image.height
73
+ end
74
+
75
+ def test_crop_resize_should_crop_and_resize_image_to_exact_dimensions
76
+ dimensions = [200,153]
77
+ assert @portrait_image.crop_resize(new_image_path, :dimensions => dimensions)
78
+ @new_image = new_imanip_image(new_image_path)
79
+ assert_equal dimensions, @new_image.dimensions
80
+
81
+ dimensions = [200,153]
82
+ assert @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
83
+ @new_image = new_imanip_image(new_image_path)
84
+ assert_equal dimensions, @new_image.dimensions
85
+
86
+ dimensions = [100,125]
87
+ assert @portrait_image.crop_resize(new_image_path, :dimensions => dimensions)
88
+ @new_image = new_imanip_image(new_image_path)
89
+ assert_equal dimensions, @new_image.dimensions
90
+
91
+ dimensions = [100,125]
92
+ assert @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
93
+ @new_image = new_imanip_image(new_image_path)
94
+ assert_equal dimensions, @new_image.dimensions
95
+ end
96
+
97
+ def test_crop_resize_should_crop_and_resize_image_to_exact_dimensions_with_square_dimensions
98
+ dimensions = [100,100]
99
+ assert @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
100
+ @new_image = new_imanip_image(new_image_path)
101
+ assert_equal dimensions, @new_image.dimensions
102
+ end
103
+
104
+ def test_crop_resize_should_return_a_imanip_image
105
+ dimensions = [100,100]
106
+ @new_image = @landscape_image.crop_resize(new_image_path, :dimensions => dimensions)
107
+ assert @new_image.is_a?(Imanip::Image)
108
+ assert_equal dimensions, @new_image.dimensions
109
+ end
110
+
111
+
112
+
113
+ def test_should_throw_errors_if_image_could_not_be_converted
114
+ assert_raise(Imanip::CouldNotConvertError) do
115
+ @portrait_image.resize(new_image_path, :v => "bad option")
116
+ end
117
+ end
118
+
119
+ protected
120
+ def new_imanip_image(path,interface = :magick)
121
+ Imanip::Image.new(path,interface)
122
+ end
123
+
124
+
125
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quirkey-imanip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Quint
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-16 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.7.0
23
+ version:
24
+ description: Super-quick image resizing using the ImageMagick command line tools
25
+ email:
26
+ - aaron@quirkey.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - License.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ files:
37
+ - History.txt
38
+ - License.txt
39
+ - Manifest.txt
40
+ - README.txt
41
+ - Rakefile
42
+ - config/hoe.rb
43
+ - config/requirements.rb
44
+ - init.rb
45
+ - install.rb
46
+ - lib/imanip.rb
47
+ - lib/imanip/errors.rb
48
+ - lib/imanip/image.rb
49
+ - lib/imanip/imanip_magick.rb
50
+ - lib/imanip/version.rb
51
+ - test/landscape_test.jpg
52
+ - test/portrait_test.jpg
53
+ - test/test_helper.rb
54
+ - test/test_imanip_magick.rb
55
+ - uninstall.rb
56
+ has_rdoc: true
57
+ homepage: http://quirkey.rubyforge.org
58
+ post_install_message: ""
59
+ rdoc_options:
60
+ - --main
61
+ - README.txt
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ requirements: []
77
+
78
+ rubyforge_project: quirkey
79
+ rubygems_version: 1.2.0
80
+ signing_key:
81
+ specification_version: 2
82
+ summary: Super-quick image resizing using the ImageMagick command line tools
83
+ test_files:
84
+ - test/test_helper.rb
85
+ - test/test_imanip_magick.rb