mojo_magick 0.4.8 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d35aee21b9f981adc52c8299fbac9468e89267a3
4
- data.tar.gz: 583961066b7f1a2051b7b0605f0735d03531b939
3
+ metadata.gz: 4f0bc8c31a0b6f8b9f8c5b217cc6dda15b83bf89
4
+ data.tar.gz: cb03f8a740c020b47cd58ed663c7f4ed15a1a590
5
5
  SHA512:
6
- metadata.gz: 83320f5d139053ea95ebc9e08e3564789dcc47fc68d1a7a086efc9e03f5a146f6c98ff628e565be16dff36291f40605a06c80873f6c3206bb764400ce14c5cac
7
- data.tar.gz: 057bda821e46d29639e1a711b469e9f87f59572b778d88e4f063d5cdbc3391a33be0f07d38dd8bf8183ece8021348a061278a079a55abc9833777d53b94f993c
6
+ metadata.gz: 6b18a88bd6d774ae1b4a7e0f14de462856d1e6ca4db78785dab40d6ea7475e13133bdfdc32ce83b2b197aa7429ed2b027071e9545728bf8053f050db0f0fd431
7
+ data.tar.gz: 374987fcec84b5b2a54e67bdd0dd4ff2c3d65efc6b992c7d1055377d809f01827b7add75314d905c3ceaffd196110267f384933318202017162648958a3b4a35
data/.gitignore CHANGED
@@ -4,5 +4,7 @@ fixtures/tmp
4
4
  coverage/
5
5
  .bundle/
6
6
  .\#*
7
+ \#*
7
8
  out.png
8
9
  out.html
10
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mojo_magick (0.4.8)
4
+ mojo_magick (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ MojoMagick is released under the MIT license
2
+
3
+ The MIT License (MIT)
4
+
5
+ Copyright (c) 2013 Jon Rogers, Steve Magley & Elliott Nelson
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
data/README.md CHANGED
@@ -2,9 +2,9 @@ MojoMagick
2
2
  ==========
3
3
 
4
4
  MojoMagick is a "dog simple, do very little" image library. It is basically a couple of stateless
5
- module methods that make it somewhat more convenient than calling ImageScience by hand.
5
+ module methods that make it somewhat more convenient than calling ImageMagick by hand.
6
6
 
7
- The main reason to use MojoMagick is that you should consolidate your ImageScience calls into
7
+ The main reason to use MojoMagick is that you should consolidate your ImageMagick calls into
8
8
  one place, so why not do it here? If you improve on this tool, send me the patch.
9
9
 
10
10
  This tool came about because I wanted a fast, simple, lightweight, nothing-goes-wrong-with-it-
@@ -132,7 +132,7 @@ complex commands.
132
132
 
133
133
  ### Create a new image with text
134
134
 
135
- Note: Use with care. If you don't have fonts installed ImageMagick can spin off wildly leaving MojoMagick not knowing what to do. For Unix/MacOSX, you should install freetype and ghostscript.
135
+ Note: Use with care. If you don't have fonts installed ImageMagick can spin off wildly leaving MojoMagick not knowing what to do. For Unix/MacOSX, you should install `freetype` and `ghostscript`.
136
136
 
137
137
  MojoMagick::convert(nil, fname) do |c|
138
138
  c.background 'black'
@@ -143,14 +143,52 @@ Note: Use with care. If you don't have fonts installed ImageMagick can spin off
143
143
  c.label 'the bird is the word'
144
144
  end
145
145
 
146
+ ### Generate a composite
147
+
148
+ MojoMagick::convert(nil, 'composite_out.png') do |c|
149
+ c.size '200x200'
150
+ c.image_block do # first layer
151
+ c.background 'blue'
152
+ c.fill 'white'
153
+ c.gravity 'northwest'
154
+ c.label 'NW'
155
+ end
156
+ c.image_block do # second layer
157
+ c.background 'transparent'
158
+ c.fill 'red'
159
+ c.gravity 'southeast'
160
+ c.label 'SE'
161
+ end
162
+ c.composite
163
+ end
164
+
165
+
146
166
  Availablility
147
167
  =============
168
+ * [Github Repo](http://github.com/rcode5/mojo_magick) This is the current canonical branch.
169
+ * Issues/Pull Requests can be submitted through the above repository.
170
+
171
+ Recent Changes
172
+ ==============
173
+
174
+ #### Version 0.5.1
148
175
 
149
- * [SVN Repo access](http://trac.misuse.org/science/wiki/MojoMagick)
150
- * Concact the author or discuss MojoMagick : [misuse.org](http://www.misuse.org/science/2008/01/30/mojomagick-ruby-image-library-for-imagemagick/)
176
+ * add `LICENSE.txt` and update README
177
+ * add `examples/` directory
178
+ * add support for fonts
179
+ * add support for building multi-layer images with image blocks (no explicit temp file creation)
180
+ * [Moved repo to rcode5](http://github.com/rcode5/mojo_magick) Current support and maintenance is happening here.
181
+ * added `simplecov` for test coverage reports
151
182
 
183
+ #### Versions 0.4.x
152
184
 
153
- #### Updates by Jon Rogers Aug 2011 (http://github.com/bunnymatic)
185
+ * Add rake tasks for gem building and tests
186
+ * code cleanup
187
+ * better handling of `gravity` parameter
188
+
189
+ #### Version 0.3.0
190
+
191
+ * Add new github repo
154
192
  * added gemspec for building gem with bundler
155
193
  * updated tests for ImageMagick 6.6
156
194
  * added ability to do fill + crop resizing
@@ -158,10 +196,15 @@ Availablility
158
196
  * [new github repo](https://github.com/bunnymatic/mojo_magick)
159
197
 
160
198
 
199
+
161
200
  References
162
201
  ==========
163
202
 
203
+ * [Original SVN MojoMagick repository](http://www.misuse.org/science/2008/01/30/mojomagick-ruby-image-library-for-imagemagick/) - Initiated and developed by Steve Midgley
164
204
  * [ImageMagick](http://www.imagemagick.org/)
205
+ * [FreeType](http://www.freetype.org)
206
+ * [Ghostscript](http://www.ghostscript.com/)
165
207
 
166
- Copyright (c) 2008 Steve Midgley, released under the MIT license
167
- Credit to Elliot Nelson for significant code contributions. Thanks Elliot!
208
+ Copyright (c) 2013 Jon Rogers
209
+ Copyright (c) 2008 Steve Midgley, released under the [MIT license](LICENSE.txt)
210
+ Credit to Elliot Nelson for significant code contributions. Thanks Elliot!
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ require 'mojo_magick'
5
+
6
+ MojoMagick::convert(nil, 'animated.gif') do |c|
7
+ c.size '200x200'
8
+ c.delay 100
9
+ c.image_block do # first layer
10
+ c.background 'blue'
11
+ c.fill 'white'
12
+ c.gravity 'northwest'
13
+ c.label 'NW'
14
+ end
15
+ c.image_block do # second layer
16
+ c.background 'transparent'
17
+ c.fill 'red'
18
+ c.gravity 'southeast'
19
+ c.label 'SE'
20
+ end
21
+ end
22
+
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ require 'mojo_magick'
5
+
6
+ MojoMagick::convert(nil, 'composite_out.png') do |c|
7
+ c.size '200x200'
8
+ c.delay 100
9
+ c.image_block do # first layer
10
+ c.background 'blue'
11
+ c.fill 'white'
12
+ c.gravity 'northwest'
13
+ c.label 'NW'
14
+ end
15
+ c.image_block do # second layer
16
+ c.background 'transparent'
17
+ c.fill 'red'
18
+ c.gravity 'southeast'
19
+ c.label 'SE'
20
+ end
21
+ c.composite
22
+ end
23
+
@@ -46,6 +46,13 @@ module MojoMagick
46
46
  file tmpfile
47
47
  end
48
48
 
49
+ def image_block(&block)
50
+ @opts << '\('
51
+ yield block
52
+ @opts << '\)'
53
+ self
54
+ end
55
+
49
56
  # Generic commands. Arguments will be formatted if necessary
50
57
  def method_missing(command, *args)
51
58
  if command.to_s[-1, 1] == '!'
@@ -1,3 +1,3 @@
1
1
  module MojoMagick
2
- VERSION = '0.4.8'
2
+ VERSION = '0.5.1'
3
3
  end
data/mojo_magick.gemspec CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.version = MojoMagick::VERSION
18
18
  s.platform = Gem::Platform::RUBY
19
19
  s.authors = ["Steve Midgley", "Elliot Nelson", "Jon Rogers"]
20
- s.email = ["public@misuse.org", "j@2rye.com"]
21
- s.homepage = "http://github.com/bunnymatic/mojo_magick"
20
+ s.email = ["public@misuse.org", "jon@rcode5.com"]
21
+ s.homepage = "http://github.com/rcode5/mojo_magick"
22
22
  s.summary = "mojo_magick-#{MojoMagick::VERSION}"
23
23
  s.description = %q{Simple Ruby stateless module interface to imagemagick.}
24
24
 
@@ -51,6 +51,17 @@ class MojoMagickTest < Test::Unit::TestCase
51
51
  assert_equal 67, new_dimensions[:width]
52
52
  end
53
53
 
54
+ def test_image_resize_with_percentage
55
+ reset_images
56
+ original_size = MojoMagick::get_image_size(@test_image)
57
+ retval = MojoMagick::resize(@test_image, @test_image, {:percent => 50})
58
+ assert_equal @test_image, retval
59
+ new_dimensions = MojoMagick::get_image_size(@test_image)
60
+ [:height, :width].each do |dim|
61
+ assert_equal (original_size[dim]/2.0).ceil, new_dimensions[dim]
62
+ end
63
+ end
64
+
54
65
  def test_shrink_with_big_dimensions
55
66
  # image shouldn't resize if we specify very large dimensions and specify "shrink_only"
56
67
  reset_images
@@ -4,7 +4,19 @@ class MojoMagickOptBuilderTest < Test::Unit::TestCase
4
4
 
5
5
  # These tests make the assumption that if we call #raw_command with the
6
6
  # correct strings, ImageMagick itself will operate correctly. We're only
7
- # verifying that the option builder produces the correct strings.
7
+ # verifying that the option builder produces the correct strings
8
+ def test_option_builder_with_blocks
9
+ # Passing in basic commands produces a string
10
+ b = MojoMagick::OptBuilder.new
11
+ b.image_block do
12
+ b.background 'red'
13
+ end
14
+ b.image_block do
15
+ b.background 'blue'
16
+ end
17
+ assert_equal '\( -background red \) \( -background blue \)', b.to_s
18
+ end
19
+
8
20
  def test_option_builder
9
21
  # Passing in basic commands produces a string
10
22
  b = MojoMagick::OptBuilder.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojo_magick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Midgley
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-11-23 00:00:00.000000000 Z
13
+ date: 2013-11-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -57,7 +57,7 @@ dependencies:
57
57
  description: Simple Ruby stateless module interface to imagemagick.
58
58
  email:
59
59
  - public@misuse.org
60
- - j@2rye.com
60
+ - jon@rcode5.com
61
61
  executables: []
62
62
  extensions: []
63
63
  extra_rdoc_files: []
@@ -66,8 +66,11 @@ files:
66
66
  - .ruby-version
67
67
  - Gemfile
68
68
  - Gemfile.lock
69
+ - LICENSE.txt
69
70
  - README.md
70
71
  - Rakefile
72
+ - examples/animated_gif.rb
73
+ - examples/composite.rb
71
74
  - init.rb
72
75
  - lib/image_magick/fonts.rb
73
76
  - lib/image_magick/resource_limits.rb
@@ -89,7 +92,7 @@ files:
89
92
  - test/parser_test.rb
90
93
  - test/resource_limits_test.rb
91
94
  - test/test_helper.rb
92
- homepage: http://github.com/bunnymatic/mojo_magick
95
+ homepage: http://github.com/rcode5/mojo_magick
93
96
  licenses: []
94
97
  metadata: {}
95
98
  post_install_message: |2+
@@ -119,7 +122,7 @@ rubyforge_project: mojo_magick
119
122
  rubygems_version: 2.0.3
120
123
  signing_key:
121
124
  specification_version: 4
122
- summary: mojo_magick-0.4.8
125
+ summary: mojo_magick-0.5.1
123
126
  test_files:
124
127
  - test/fixtures/5742.jpg
125
128
  - test/fixtures/not_an_image.jpg