imanip 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.txt +34 -30
- data/lib/imanip/imanip_magick.rb +2 -0
- data/lib/imanip/version.rb +1 -1
- data/test/test_imanip_magick.rb +4 -0
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -9,18 +9,18 @@ Super-quick image resizing using the ImageMagick command line tools
|
|
9
9
|
|
10
10
|
== FEATURES/PROBLEMS:
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
- Simple API
|
13
|
+
- 0% Overhead
|
14
|
+
- Uses the ImageMagick command line tools (convert, identify)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
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
19
|
|
20
20
|
== SYNOPSIS:
|
21
21
|
|
22
22
|
|
23
|
-
|
23
|
+
First things, first, Tell me where you keep them:
|
24
24
|
|
25
25
|
|
26
26
|
# Rails: production|development|etc.rb
|
@@ -29,70 +29,74 @@ Super-quick image resizing using the ImageMagick command line tools
|
|
29
29
|
Imanip::Interface::Magick.execute_path = '/path/to/your/bins/' # eg /usr/local/bin/
|
30
30
|
|
31
31
|
|
32
|
-
|
32
|
+
With an image file at /dir/image.jpg
|
33
33
|
|
34
34
|
image = Imanip::Image.new('/dir/image.jpg')
|
35
35
|
|
36
|
-
|
37
|
-
|
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
|
38
39
|
|
39
40
|
image.width #=> 410 (Fixnum)
|
40
41
|
image.height #=> 100 (Fixnum)
|
41
42
|
image.format #=> JPEG (String)
|
42
43
|
|
43
|
-
|
44
|
+
There are also some helpers to do some rule based cropping.
|
44
45
|
|
45
46
|
image.portrait? #=> false
|
46
47
|
image.landscape? #=> true
|
47
48
|
image.orientation #=> :landscape
|
48
49
|
|
49
|
-
|
50
|
+
After that you can resize and whatever
|
50
51
|
|
51
52
|
image.resize('outputfile.jpg', :dimensions => [200,100])
|
52
53
|
|
53
|
-
|
54
|
+
I like crop_resize better. It crops AND resizes so you get an image of the exact pixel dimensions you desire.
|
54
55
|
|
55
56
|
image.crop_resize('/file/to/output.jpg', :width => 50, :height => 50) #=> output file is an exact 50x50 image
|
56
57
|
|
57
|
-
|
58
|
+
You might also want to catch errors, because they will inevitably happen. Possible Errors
|
59
|
+
|
58
60
|
Imanip::Error # the root, the root, the root is on fire
|
59
61
|
Imanip::NotAnImageError # Descends from above, thrown during Imanip#Image.new
|
60
62
|
Imanip::CouldNotConvertError # Also from above, thrown if theres an issue with #resize or #crop_resize (options, etc.)
|
61
63
|
|
62
|
-
|
64
|
+
More examples coming soon.
|
63
65
|
|
64
66
|
== REQUIREMENTS:
|
65
67
|
|
66
|
-
|
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
|
68
71
|
|
69
72
|
|
70
73
|
== INSTALL:
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
First, install ImageMagick:
|
76
|
+
http://www.imagemagick.org/script/download.php
|
77
|
+
|
78
|
+
Make sure you get the command line tools:
|
76
79
|
|
77
80
|
$ which 'convert'
|
78
81
|
|
79
|
-
|
82
|
+
Imanip works as a gem or a plugin for Rails.
|
80
83
|
|
81
|
-
|
84
|
+
As a gem:
|
82
85
|
|
83
86
|
$ sudo gem install imanip
|
84
87
|
|
85
|
-
|
88
|
+
In Rails/environment.rb
|
86
89
|
config.gem 'imanip'
|
87
90
|
|
88
|
-
|
89
|
-
$ sudo gem sources -a http://gems.github.com
|
90
|
-
$ sudo gem install quirkey-imanip
|
91
|
-
|
91
|
+
Or you can get the ABSOLUTE latest from github:
|
92
92
|
|
93
|
-
|
93
|
+
$ sudo gem install quirkey-imanip -s http://gems.github.com
|
94
94
|
|
95
|
-
(
|
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:
|
96
100
|
|
97
101
|
Copyright (c) 2008 Aaron Quint, Quirkey
|
98
102
|
|
data/lib/imanip/imanip_magick.rb
CHANGED
data/lib/imanip/version.rb
CHANGED
data/test/test_imanip_magick.rb
CHANGED
@@ -17,6 +17,10 @@ class ImanipMagickTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_should_return_an_imanip_image
|
21
|
+
assert @portrait_image.is_a?(Imanip::Image)
|
22
|
+
end
|
23
|
+
|
20
24
|
def test_should_return_dimensions_as_array
|
21
25
|
dimensions = @portrait_image.dimensions
|
22
26
|
assert dimensions.is_a?(Array)
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Quint
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-06-
|
12
|
+
date: 2008-06-16 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|