mini_magick 1.2.3 → 1.3.0

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.
data/MIT-LICENSE CHANGED
File without changes
data/README.rdoc ADDED
@@ -0,0 +1,75 @@
1
+ = MiniMagick
2
+
3
+ NOTE: I'm not actively using MiniMagick anymore and am looking to hand it off
4
+ to someone with more interest. Contact me through github if that person is you!
5
+
6
+ A ruby wrapper for ImageMagick or GraphicsMagick command line.
7
+
8
+
9
+ == Why?
10
+
11
+ I was using RMagick and loving it, but it was eating up huge amounts
12
+ of memory. A simple script like this...
13
+
14
+ Magick::read("image.jpg") do |f|
15
+ f.write("manipulated.jpg")
16
+ end
17
+
18
+ ...would use over 100 Megs of Ram. On my local machine this wasn't a
19
+ problem, but on my hosting server the ruby apps would crash because of
20
+ their 100 Meg memory limit.
21
+
22
+
23
+ == Solution!
24
+
25
+ Using MiniMagick the ruby processes memory remains small (it spawns
26
+ ImageMagick's command line program mogrify which takes up some memory
27
+ as well, but is much smaller compared to RMagick)
28
+
29
+ MiniMagick gives you access to all the commandline options ImageMagick
30
+ has (Found here http://www.imagemagick.org/script/mogrify.php)
31
+
32
+
33
+ == Examples
34
+
35
+ Want to make a thumbnail from a file...
36
+
37
+ image = MiniMagick::Image.from_file("input.jpg")
38
+ image.resize "100x100"
39
+ image.write("output.jpg")
40
+
41
+ Want to make a thumbnail from a blob...
42
+
43
+ image = MiniMagick::Image.from_blob(blob)
44
+ image.resize "100x100"
45
+ image.write("output.jpg")
46
+
47
+ Need to combine several options?
48
+
49
+ image = MiniMagick::Image.from_file("input.jpg")
50
+ image.combine_options do |c|
51
+ c.sample "50%"
52
+ c.rotate "-90>"
53
+ end
54
+ image.write("output.jpg")
55
+
56
+ Want to manipulate an image at its source (You won't have to write it
57
+ out because the transformations are done on that file)
58
+
59
+ image = MiniMagick::Image.new("input.jpg")
60
+ image.resize "100x100"
61
+
62
+ Want to get some meta-information out?
63
+
64
+ image = MiniMagick::Image.from_file("input.jpg")
65
+ image[:width] # will get the width (you can also use :height and :format)
66
+ image["EXIF:BitsPerSample"] # It also can get all the EXIF tags
67
+ image["%m:%f %wx%h"] # Or you can use one of the many options of the format command
68
+
69
+ For more on the format command see
70
+ http://www.imagemagick.org/script/command-line-options.php#format
71
+
72
+
73
+ == Requirements
74
+
75
+ You must have ImageMagick or GraphicsMagick installed.
data/Rakefile CHANGED
@@ -1,17 +1,32 @@
1
- # -*- ruby -*-
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
2
5
 
3
- require 'rubygems'
4
- require 'hoe'
5
- require './lib/mini_magick.rb'
6
+ $:.unshift(File.dirname(__FILE__) + "/lib")
7
+ require 'mini_magick'
6
8
 
7
- Hoe.new('mini_magick', MiniMagick::VERSION) do |p|
8
- p.rubyforge_name = 'mini_magick'
9
- p.author = 'Corey Johnson'
10
- p.email = 'probablycorey+ruby@gmail.com'
11
- p.summary = 'A simple image manipulation library based on ImageMagick.'
12
- p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
- #p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
9
+ desc 'Default: run unit tests.'
10
+ task :default => :test
11
+
12
+ desc 'Test the mini_magick plugin.'
13
+ Rake::TestTask.new(:test) do |t|
14
+ t.libs << 'test'
15
+ t.pattern = 'test/**/*_test.rb'
16
+ t.verbose = true
17
+ end
18
+
19
+ desc 'Generate documentation for the mini_magick plugin.'
20
+ Rake::RDocTask.new(:rdoc) do |rdoc|
21
+ rdoc.rdoc_dir = 'rdoc'
22
+ rdoc.title = 'MiniMagick'
23
+ rdoc.options << '--line-numbers'
24
+ rdoc.options << '--inline-source'
25
+ rdoc.rdoc_files.include('README.rdoc')
26
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
27
  end
16
28
 
17
- # vim: syntax=Ruby
29
+ spec = eval(File.read('mini_magick.gemspec'))
30
+ Rake::GemPackageTask.new(spec) do |pkg|
31
+ pkg.gem_spec = spec
32
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.0
@@ -0,0 +1,2 @@
1
+ require 'mini_magick'
2
+ MiniMagick.processor = :gm
data/lib/mini_magick.rb CHANGED
@@ -1,13 +1,14 @@
1
- require "open-uri"
2
- require "stringio"
3
- require "fileutils"
4
-
5
- require File.join(File.dirname(__FILE__), '/image_temp_file')
1
+ require 'tempfile'
2
+ require 'subexec'
6
3
 
7
4
  module MiniMagick
8
- class MiniMagickError < RuntimeError; end
9
-
10
- VERSION = '1.2.3'
5
+ class << self
6
+ attr_accessor :processor
7
+ attr_accessor :timeout
8
+ end
9
+
10
+ class Error < RuntimeError; end
11
+ class Invalid < StandardError; end
11
12
 
12
13
  class Image
13
14
  attr :path
@@ -16,25 +17,26 @@ module MiniMagick
16
17
 
17
18
  # Class Methods
18
19
  # -------------
19
- class <<self
20
- def from_blob(blob, extension=nil)
20
+ class << self
21
+ def from_blob(blob, ext = nil)
21
22
  begin
22
- tempfile = ImageTempFile.new("minimagick#{extension}")
23
+ tempfile = Tempfile.new(['mini_magick', ext.to_s])
23
24
  tempfile.binmode
24
25
  tempfile.write(blob)
25
26
  ensure
26
- tempfile.close
27
+ tempfile.close if tempfile
27
28
  end
28
-
29
+
29
30
  return self.new(tempfile.path, tempfile)
30
31
  end
31
32
 
32
33
  # Use this if you don't want to overwrite the image file
33
- def from_file(image_path)
34
+ def open(image_path)
34
35
  File.open(image_path, "rb") do |f|
35
36
  self.from_blob(f.read, File.extname(image_path))
36
37
  end
37
38
  end
39
+ alias_method :from_file, :open
38
40
  end
39
41
 
40
42
  # Instance Methods
@@ -57,6 +59,10 @@ module MiniMagick
57
59
  run_command("identify", "-format", format_option("%h"), @path).split("\n")[0].to_i
58
60
  when "width"
59
61
  run_command("identify", "-format", format_option("%w"), @path).split("\n")[0].to_i
62
+ when "dimensions"
63
+ run_command("identify", "-format", format_option("%w %h"), @path).split("\n")[0].split.map{|v|v.to_i}
64
+ when "size"
65
+ File.size(@path) # Do this because calling identify -format "%b" on an animated gif fails!
60
66
  when "original_at"
61
67
  # Get the EXIF original capture as a Time object
62
68
  Time.local(*self["EXIF:DateTimeOriginal"].split(/:|\s+/)) rescue nil
@@ -67,12 +73,39 @@ module MiniMagick
67
73
  end
68
74
  end
69
75
 
76
+ # Sends raw commands to imagemagick's mogrify command. The image path is automatically appended to the command
77
+ def <<(*args)
78
+ run_command("mogrify", *args << @path)
79
+ end
80
+
70
81
  # This is a 'special' command because it needs to change @path to reflect the new extension
71
- def format(format)
82
+ # Formatting an animation into a non-animated type will result in ImageMagick creating multiple
83
+ # pages (starting with 0). You can choose which page you want to manipulate. We default to the
84
+ # first page.
85
+ def format(format, page=0)
72
86
  run_command("mogrify", "-format", format, @path)
73
- @path = @path.sub(/(\.\w+)?$/, ".#{format}")
74
-
75
- raise "Unable to format to #{format}" unless File.exists?(@path)
87
+
88
+ old_path = @path.dup
89
+ @path.sub!(/(\.\w*)?$/, ".#{format}")
90
+ File.delete(old_path) unless old_path == @path
91
+
92
+ unless File.exists?(@path)
93
+ begin
94
+ FileUtils.copy_file(@path.sub(".#{format}", "-#{page}.#{format}"), @path)
95
+ rescue => ex
96
+ raise MiniMagickError, "Unable to format to #{format}; #{ex}" unless File.exist?(@path)
97
+ end
98
+ end
99
+ ensure
100
+ Dir[@path.sub(/(\.\w+)?$/, "-[0-9]*.#{format}")].each do |fname|
101
+ File.unlink(fname)
102
+ end
103
+ end
104
+
105
+ # Collapse images with sequences to the first frame (ie. animated gifs) and
106
+ # preserve quality
107
+ def collapse!
108
+ run_command("mogrify", "-quality", "100", "#{path}[0]")
76
109
  end
77
110
 
78
111
  # Writes the temporary image that we are using for processing to the output path
@@ -83,7 +116,11 @@ module MiniMagick
83
116
 
84
117
  # Give you raw data back
85
118
  def to_blob
86
- File.read @path
119
+ f = File.new @path
120
+ f.binmode
121
+ f.read
122
+ ensure
123
+ f.close if f
87
124
  end
88
125
 
89
126
  # If an unknown method is called then it is sent through the morgrify program
@@ -112,20 +149,38 @@ module MiniMagick
112
149
  end
113
150
 
114
151
  def run_command(command, *args)
115
- args.collect! do |arg|
116
- arg = arg.to_s
117
- arg = %|"#{arg}"| unless arg[0] == ?- # values quoted because they can contain characters like '>', but don't quote switches
118
- arg
152
+ args.collect! do |arg|
153
+ # args can contain characters like '>' so we must escape them, but don't quote switches
154
+ if arg !~ /^[\+\-]/
155
+ "\"#{arg}\""
156
+ else
157
+ arg.to_s
158
+ end
119
159
  end
120
160
 
121
- @output = `#{command} #{args.join(' ')}`
122
-
123
- if $? != 0
124
- raise MiniMagickError, "ImageMagick command (#{command} #{args.join(' ')}) failed: Error Given #{$?}"
161
+ command = "#{MiniMagick.processor} #{command} #{args.join(' ')}".strip
162
+ sub = Subexec.run(command, :timeout => MiniMagick.timeout)
163
+
164
+ if sub.exitstatus != 0
165
+ # Clean up after ourselves in case of an error
166
+ destroy!
167
+
168
+ # Raise the appropriate error
169
+ if sub.output =~ /no decode delegate/i || sub.output =~ /did not return an image/i
170
+ raise Invalid, sub.output
171
+ else
172
+ raise Error, "Command (#{command.inspect}) failed: #{{:status_code => sub.exitstatus, :output => sub.output}.inspect}"
173
+ end
125
174
  else
126
- @output
175
+ sub.output
127
176
  end
128
177
  end
178
+
179
+ def destroy!
180
+ return if tempfile.nil?
181
+ File.unlink(tempfile.path)
182
+ @tempfile = nil
183
+ end
129
184
  end
130
185
 
131
186
  class CommandBuilder
@@ -139,7 +194,7 @@ module MiniMagick
139
194
  @args << "-#{symbol}"
140
195
  @args += args
141
196
  end
142
-
197
+
143
198
  def +(value)
144
199
  @args << "+#{value}"
145
200
  end
File without changes
Binary file
@@ -0,0 +1,20 @@
1
+ require 'test/unit'
2
+ require File.join(File.dirname(__FILE__), '../lib/mini_magick')
3
+
4
+ class CommandBuilderTest < Test::Unit::TestCase
5
+ include MiniMagick
6
+
7
+ def test_basic
8
+ c = CommandBuilder.new
9
+ c.resize "30x40"
10
+ assert_equal "-resize 30x40", c.args.join(" ")
11
+ end
12
+
13
+ def test_complicated
14
+ c = CommandBuilder.new
15
+ c.resize "30x40"
16
+ c.input 1, 3, 4
17
+ c.lingo "mome fingo"
18
+ assert_equal "-resize 30x40 -input 1 3 4 -lingo mome fingo", c.args.join(" ")
19
+ end
20
+ end
@@ -1,68 +1,94 @@
1
1
  require 'test/unit'
2
2
  require File.join(File.dirname(__FILE__), '../lib/mini_magick')
3
3
 
4
+ MiniMagick.processor = :gm
5
+
4
6
  class ImageTest < Test::Unit::TestCase
5
7
  include MiniMagick
6
-
8
+
7
9
  CURRENT_DIR = File.dirname(File.expand_path(__FILE__)) + "/"
8
10
 
9
11
  SIMPLE_IMAGE_PATH = CURRENT_DIR + "simple.gif"
10
- TIFF_IMAGE_PATH = CURRENT_DIR + "burner.tiff"
12
+ MINUS_IMAGE_PATH = CURRENT_DIR + "simple-minus.gif"
13
+ TIFF_IMAGE_PATH = CURRENT_DIR + "leaves.tiff"
11
14
  NOT_AN_IMAGE_PATH = CURRENT_DIR + "not_an_image.php"
12
15
  GIF_WITH_JPG_EXT = CURRENT_DIR + "actually_a_gif.jpg"
13
16
  EXIF_IMAGE_PATH = CURRENT_DIR + "trogdor.jpg"
14
-
17
+ ANIMATION_PATH = CURRENT_DIR + "animation.gif"
18
+
15
19
  def test_image_from_blob
16
20
  File.open(SIMPLE_IMAGE_PATH, "rb") do |f|
17
21
  image = Image.from_blob(f.read)
22
+ image.destroy!
18
23
  end
19
24
  end
20
-
25
+
21
26
  def test_image_from_file
22
27
  image = Image.from_file(SIMPLE_IMAGE_PATH)
28
+ image.destroy!
23
29
  end
24
-
30
+
25
31
  def test_image_new
26
32
  image = Image.new(SIMPLE_IMAGE_PATH)
33
+ image.destroy!
27
34
  end
28
-
35
+
29
36
  def test_image_write
30
37
  output_path = "output.gif"
31
38
  begin
32
39
  image = Image.new(SIMPLE_IMAGE_PATH)
33
40
  image.write output_path
34
-
41
+
35
42
  assert File.exists?(output_path)
36
43
  ensure
37
44
  File.delete output_path
38
45
  end
46
+ image.destroy!
39
47
  end
40
-
48
+
41
49
  def test_not_an_image
42
- assert_raise(MiniMagickError) do
50
+ assert_raise(MiniMagick::Invalid) do
43
51
  image = Image.new(NOT_AN_IMAGE_PATH)
52
+ image.destroy!
44
53
  end
45
54
  end
46
-
55
+
47
56
  def test_image_meta_info
48
57
  image = Image.new(SIMPLE_IMAGE_PATH)
49
58
  assert_equal 150, image[:width]
50
59
  assert_equal 55, image[:height]
60
+ assert_equal [150, 55], image[:dimensions]
51
61
  assert_match(/^gif$/i, image[:format])
62
+ image.destroy!
52
63
  end
53
64
 
54
65
  def test_tiff
55
- image = Image.new(TIFF_IMAGE_PATH)
66
+ image = Image.new(TIFF_IMAGE_PATH)
56
67
  assert_equal "tiff", image[:format].downcase
57
- assert_equal 317, image[:width]
58
- assert_equal 275, image[:height]
68
+ assert_equal 295, image[:width]
69
+ assert_equal 242, image[:height]
70
+ image.destroy!
59
71
  end
60
-
72
+
73
+ # def test_animation_pages
74
+ # image = Image.from_file(ANIMATION_PATH)
75
+ # image.format "png", 0
76
+ # assert_equal "png", image[:format].downcase
77
+ # image.destroy!
78
+ # end
79
+
80
+ # def test_animation_size
81
+ # image = Image.from_file(ANIMATION_PATH)
82
+ # assert_equal image[:size], 76631
83
+ # image.destroy!
84
+ # end
85
+
61
86
  def test_gif_with_jpg_format
62
- image = Image.new(GIF_WITH_JPG_EXT)
87
+ image = Image.new(GIF_WITH_JPG_EXT)
63
88
  assert_equal "gif", image[:format].downcase
89
+ image.destroy!
64
90
  end
65
-
91
+
66
92
  def test_image_resize
67
93
  image = Image.from_file(SIMPLE_IMAGE_PATH)
68
94
  image.resize "20x30!"
@@ -70,8 +96,9 @@ class ImageTest < Test::Unit::TestCase
70
96
  assert_equal 20, image[:width]
71
97
  assert_equal 30, image[:height]
72
98
  assert_match(/^gif$/i, image[:format])
73
- end
74
-
99
+ image.destroy!
100
+ end
101
+
75
102
  def test_image_resize_with_minimum
76
103
  image = Image.from_file(SIMPLE_IMAGE_PATH)
77
104
  original_width, original_height = image[:width], image[:height]
@@ -79,8 +106,9 @@ class ImageTest < Test::Unit::TestCase
79
106
 
80
107
  assert_equal original_width, image[:width]
81
108
  assert_equal original_height, image[:height]
109
+ image.destroy!
82
110
  end
83
-
111
+
84
112
  def test_image_combine_options_resize_blur
85
113
  image = Image.from_file(SIMPLE_IMAGE_PATH)
86
114
  image.combine_options do |c|
@@ -91,37 +119,60 @@ class ImageTest < Test::Unit::TestCase
91
119
  assert_equal 20, image[:width]
92
120
  assert_equal 30, image[:height]
93
121
  assert_match(/^gif$/i, image[:format])
122
+ image.destroy!
94
123
  end
95
124
 
125
+ def test_image_combine_options_with_filename_with_minusses_in_it
126
+ image = Image.from_file(SIMPLE_IMAGE_PATH)
127
+ assert_nothing_raised do
128
+ image.combine_options do |c|
129
+ c.draw "image Over 0,0 10,10 '#{MINUS_IMAGE_PATH}'"
130
+ end
131
+ end
132
+ image.destroy!
133
+ end
134
+
96
135
  def test_exif
97
136
  image = Image.from_file(EXIF_IMAGE_PATH)
98
137
  assert_equal('0220', image["exif:ExifVersion"])
99
138
  image = Image.from_file(SIMPLE_IMAGE_PATH)
100
139
  assert_equal('', image["EXIF:ExifVersion"])
140
+ image.destroy!
101
141
  end
102
-
142
+
103
143
  def test_original_at
104
144
  image = Image.from_file(EXIF_IMAGE_PATH)
105
145
  assert_equal(Time.local('2005', '2', '23', '23', '17', '24'), image[:original_at])
106
146
  image = Image.from_file(SIMPLE_IMAGE_PATH)
107
147
  assert_nil(image[:original_at])
148
+ image.destroy!
108
149
  end
109
- end
110
150
 
111
- class CommandBuilderTest < Test::Unit::TestCase
112
- include MiniMagick
113
-
114
- def test_basic
115
- c = CommandBuilder.new
116
- c.resize "30x40"
117
- assert_equal "-resize 30x40", c.args.join(" ")
151
+ def test_tempfile_at_path
152
+ image = Image.from_file(TIFF_IMAGE_PATH)
153
+ assert_equal image.path, image.tempfile.path
154
+ image.destroy!
118
155
  end
119
-
120
- def test_complicated
121
- c = CommandBuilder.new
122
- c.resize "30x40"
123
- c.input 1, 3, 4
124
- c.lingo "mome fingo"
125
- assert_equal "-resize 30x40 -input 1 3 4 -lingo mome fingo", c.args.join(" ")
156
+
157
+ def test_tempfile_at_path_after_format
158
+ image = Image.from_file(TIFF_IMAGE_PATH)
159
+ image.format('png')
160
+ assert_equal image.path, image.tempfile.path
161
+ image.destroy!
162
+ end
163
+
164
+ def test_previous_tempfile_deleted_after_format
165
+ image = Image.from_file(TIFF_IMAGE_PATH)
166
+ before = image.path.dup
167
+ image.format('png')
168
+ assert !File.exist?(before)
169
+ image.destroy!
126
170
  end
171
+
172
+ # def test_mini_magick_error_when_referencing_not_existing_page
173
+ # image = Image.from_file(ANIMATION_PATH)
174
+ # image.format('png')
175
+ # assert_equal image[:format], 'PNG'
176
+ # image.destroy!
177
+ # end
127
178
  end
data/test/leaves.tiff ADDED
Binary file
File without changes
Binary file
data/test/simple.gif CHANGED
File without changes
data/test/trogdor.jpg CHANGED
File without changes
metadata CHANGED
@@ -1,71 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.1
3
- specification_version: 1
4
2
  name: mini_magick
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.2.3
7
- date: 2007-06-15 00:00:00 -04:00
8
- summary: A simple image manipulation library based on ImageMagick.
9
- require_paths:
10
- - lib
11
- email: probablycorey+ruby@gmail.com
12
- homepage: http://www.zenspider.com/ZSS/Products/mini_magick/
13
- rubyforge_project: mini_magick
14
- description: "- Why? I was using RMagick and loving it, but it was eating up huge amounts of memory. A simple script like this... Magick::read(\"image.jpg\") do |f| f.write(\"manipulated.jpg\") end ...would use over 100 Megs of Ram. On my local machine this wasn't a problem, but on my hosting server the ruby apps would crash because of their 100 Meg memory limit."
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
25
11
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
12
  authors:
30
13
  - Corey Johnson
14
+ - Peter Kieltyka
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-07-02 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: subexec
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 27
31
+ segments:
32
+ - 0
33
+ - 0
34
+ - 2
35
+ version: 0.0.2
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ description: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
39
+ email:
40
+ - probablycorey@gmail.com
41
+ - peter@nulayer.com
42
+ executables: []
43
+
44
+ extensions: []
45
+
46
+ extra_rdoc_files: []
47
+
31
48
  files:
49
+ - README.rdoc
50
+ - VERSION
32
51
  - MIT-LICENSE
33
- - History.txt
34
- - Manifest.txt
35
- - README.txt
36
52
  - Rakefile
37
- - init.rb
38
- - lib/image_temp_file.rb
53
+ - lib/mini_gmagick.rb
39
54
  - lib/mini_magick.rb
40
55
  - test/actually_a_gif.jpg
56
+ - test/animation.gif
57
+ - test/command_builder_test.rb
58
+ - test/image_test.rb
59
+ - test/leaves.tiff
41
60
  - test/not_an_image.php
61
+ - test/simple-minus.gif
42
62
  - test/simple.gif
43
- - test/test_image_temp_file.rb
44
- - test/test_mini_magick_test.rb
45
63
  - test/trogdor.jpg
46
- test_files:
47
- - test/test_image_temp_file.rb
48
- - test/test_mini_magick_test.rb
49
- rdoc_options:
50
- - --main
51
- - README.txt
52
- extra_rdoc_files:
53
- - History.txt
54
- - Manifest.txt
55
- - README.txt
56
- executables: []
64
+ has_rdoc: true
65
+ homepage: http://github.com/nulayer/mini_magick
66
+ licenses: []
57
67
 
58
- extensions: []
68
+ post_install_message:
69
+ rdoc_options: []
59
70
 
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
60
91
  requirements: []
61
92
 
62
- dependencies:
63
- - !ruby/object:Gem::Dependency
64
- name: hoe
65
- version_requirement:
66
- version_requirements: !ruby/object:Gem::Version::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 1.2.1
71
- version:
93
+ rubyforge_project:
94
+ rubygems_version: 1.3.7
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
98
+ test_files:
99
+ - test/actually_a_gif.jpg
100
+ - test/animation.gif
101
+ - test/command_builder_test.rb
102
+ - test/image_test.rb
103
+ - test/leaves.tiff
104
+ - test/not_an_image.php
105
+ - test/simple-minus.gif
106
+ - test/simple.gif
107
+ - test/trogdor.jpg
data/History.txt DELETED
@@ -1,11 +0,0 @@
1
- == 1.2.2 / 2007-06-01
2
-
3
- # 1.) all image commands return the image object (The output of the last command is saved in @output)
4
- # 2.) identify doesn't trip over strangley named files
5
- # 3.) TempFile uses file extention now (Thanks http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions)
6
- # 4.) identify commands escape output path correctly
7
-
8
- == 1.2.3 / 2007-06-15
9
-
10
- # 1.) Image::from_file doesn't drop the file extension anymore, it and use the image_temp_file correctly
11
- # 4.) TempFiles are stored as an instance variable in Image instances so they don't get cleaned up prematurely via garbage collection
data/Manifest.txt DELETED
@@ -1,14 +0,0 @@
1
- MIT-LICENSE
2
- History.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- init.rb
7
- lib/image_temp_file.rb
8
- lib/mini_magick.rb
9
- test/actually_a_gif.jpg
10
- test/not_an_image.php
11
- test/simple.gif
12
- test/test_image_temp_file.rb
13
- test/test_mini_magick_test.rb
14
- test/trogdor.jpg
data/README.txt DELETED
@@ -1,101 +0,0 @@
1
- mini_magick
2
- by Coery Johnson
3
- FIX (url)
4
-
5
- == DESCRIPTION:
6
-
7
- A ruby wrapper for ImageMagick command line.
8
-
9
- - Why?
10
-
11
- I was using RMagick and loving it, but it was eating up huge amounts of memory. A simple script like this...
12
-
13
- Magick::read("image.jpg") do |f|
14
- f.write("manipulated.jpg")
15
- end
16
-
17
- ...would use over 100 Megs of Ram. On my local machine this wasn't a problem, but on my hosting server the ruby apps would crash because of their 100 Meg memory limit.
18
-
19
- - Solution!
20
-
21
- Using MiniMagick the ruby processes memory remains small (it spawns ImageMagick's command line program mogrify which takes up some memory as well, but is much smaller compared to RMagick)
22
-
23
-
24
- == FEATURES/PROBLEMS:
25
-
26
- MiniMagick gives you access to all the commandline options ImageMagick has (Found here http://www.imagemagick.org/script/mogrify.php)
27
-
28
- == SYNOPSIS:
29
-
30
- Want to make a thumbnail from a file...
31
-
32
- image = MiniMagick::Image.from_file("input.jpg")
33
- image.resize "100x100"
34
- image.write("output.jpg")
35
-
36
- Want to make a thumbnail from a blob...
37
-
38
- image = MiniMagick::Image.from_blob(blob)
39
- image.resize "100x100"
40
- image.write("output.jpg")
41
-
42
- Need to combine several options?
43
-
44
- image = MiniMagick::Image.from_file("input.jpg")
45
- image.combine_options do |c|
46
- c.sample "50%"
47
- c.rotate "-90>"
48
- end
49
- image.write("output.jpg")
50
-
51
- Want to manipulate an image at its source (You won't have to write it out because the transformations are done on that file)
52
-
53
- image = MiniMagick::Image.new("input.jpg")
54
- image.resize "100x100"
55
-
56
- Want to get some meta-information out?
57
-
58
- image = MiniMagick::Image.from_file("input.jpg")
59
- image[:width] # will get the width (you can also use :height and :format)
60
- image["EXIF:BitsPerSample"] # It also can get all the EXIF tags
61
- image["%m:%f %wx%h"] # Or you can use one of the many options of the format command found here http://www.imagemagick.org/script/command-line-options.php#format
62
-
63
-
64
- == REQUIREMENTS:
65
-
66
- You must have ImageMagick installed.
67
-
68
- == INSTALL:
69
-
70
- If you downloaded the plugin version, just drop the plugin into RAILS_ROOT/plugins/
71
-
72
- If you installed this as a gem, then to get it to work add <require "mini_magick"> to RAILS_ROOT/config/environment.rb
73
-
74
- If you have just downloaded this files then copy the mini_magick.rb file into your RAILS_ROOT/lib directory and add <require "mini-magick"> to RAILS_ROOT/config/environment.rb
75
-
76
- MiniMagick does NOT require rails though. All the code you need to use MiniMagick is located in the mini_magick/lib/mini_magick.rb file.
77
-
78
- == LICENSE:
79
-
80
- (The MIT License)
81
-
82
- Copyright (c) 2007 FIX
83
-
84
- Permission is hereby granted, free of charge, to any person obtaining
85
- a copy of this software and associated documentation files (the
86
- 'Software'), to deal in the Software without restriction, including
87
- without limitation the rights to use, copy, modify, merge, publish,
88
- distribute, sublicense, and/or sell copies of the Software, and to
89
- permit persons to whom the Software is furnished to do so, subject to
90
- the following conditions:
91
-
92
- The above copyright notice and this permission notice shall be
93
- included in all copies or substantial portions of the Software.
94
-
95
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
96
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
97
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
98
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
99
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
100
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
101
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/init.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'mini_magick'
2
- require 'image_temp_file'
@@ -1,13 +0,0 @@
1
- require "tempfile"
2
-
3
- module MiniMagick
4
- class ImageTempFile < Tempfile
5
- def make_tmpname(basename, n)
6
- # force tempfile to use basename's extension if provided
7
- ext = File.extname(basename)
8
-
9
- # force hyphens instead of periods in name
10
- sprintf('%s%d-%d%s', File.basename(basename, ext), $$, n, ext)
11
- end
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- require 'test/unit'
2
- require File.join(File.dirname(__FILE__), '../lib/image_temp_file')
3
-
4
- class ImageTest < Test::Unit::TestCase
5
- include MiniMagick
6
-
7
- def test_image_temp_file
8
- tmp = ImageTempFile.new('test')
9
- assert_match %r{^test}, File::basename(tmp.path)
10
- tmp = ImageTempFile.new('test.jpg')
11
- assert_match %r{^test}, File::basename(tmp.path)
12
- assert_match %r{\.jpg$}, File::basename(tmp.path)
13
- end
14
- end