forked from minimagick/minimagick
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gobbled up a bunch of remvees patches
- Loading branch information
1 parent
56a4761
commit 88f0328
Showing
32 changed files
with
399 additions
and
2,194 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
= MiniMagick | ||
|
||
A ruby wrapper for ImageMagick command line. | ||
|
||
|
||
== 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. | ||
|
||
|
||
== Solution! | ||
|
||
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) | ||
|
||
MiniMagick gives you access to all the commandline options ImageMagick | ||
has (Found here http://www.imagemagick.org/script/mogrify.php) | ||
|
||
|
||
== Examples | ||
|
||
Want to make a thumbnail from a file... | ||
|
||
image = MiniMagick::Image.from_file("input.jpg") | ||
image.resize "100x100" | ||
image.write("output.jpg") | ||
|
||
Want to make a thumbnail from a blob... | ||
|
||
image = MiniMagick::Image.from_blob(blob) | ||
image.resize "100x100" | ||
image.write("output.jpg") | ||
|
||
Need to combine several options? | ||
|
||
image = MiniMagick::Image.from_file("input.jpg") | ||
image.combine_options do |c| | ||
c.sample "50%" | ||
c.rotate "-90>" | ||
end | ||
image.write("output.jpg") | ||
|
||
Want to manipulate an image at its source (You won't have to write it | ||
out because the transformations are done on that file) | ||
|
||
image = MiniMagick::Image.new("input.jpg") | ||
image.resize "100x100" | ||
|
||
Want to get some meta-information out? | ||
|
||
image = MiniMagick::Image.from_file("input.jpg") | ||
image[:width] # will get the width (you can also use :height and :format) | ||
image["EXIF:BitsPerSample"] # It also can get all the EXIF tags | ||
image["%m:%f %wx%h"] # Or you can use one of the many options of the format command | ||
|
||
For more on the format command see | ||
http://www.imagemagick.org/script/command-line-options.php#format | ||
|
||
|
||
== Requirements | ||
|
||
You must have ImageMagick installed. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
require 'config/requirements' | ||
require 'config/hoe' # setup Hoe + all gem configuration | ||
|
||
Dir['tasks/**/*.rake'].each { |rake| load rake } | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
$:.unshift(File.dirname(__FILE__) + "/lib") | ||
require 'mini_magick' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Clean generated files.' | ||
task :clean => :clobber_rdoc do | ||
rm FileList['test/output/*.png'] | ||
end | ||
|
||
desc 'Test the mini_magick plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the mini_magick plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'MiniMagick' | ||
rdoc.options << '--line-numbers' | ||
rdoc.options << '--inline-source' | ||
rdoc.rdoc_files.include('README.rdoc') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
||
desc 'Update gemspec.' | ||
task :update_gemspec => :clean do | ||
files = `git-ls-files`.split | ||
data = File.read('mini_magick.gemspec') | ||
data.sub!(/^ s.version = .*$/, " s.version = #{MiniMagick::VERSION.inspect}") | ||
data.sub!(/^ s.files = .*$/, " s.files = %w(#{files.join(' ')})") | ||
open('mini_magick.gemspec', 'w'){|f| f.write(data)} | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "tempfile" | ||
|
||
module MiniMagick | ||
class ImageTempFile < Tempfile | ||
def make_tmpname(ext, n) | ||
'mini_magick%d-%d%s' % [$$, n, ext ? ".#{ext}" : ''] | ||
end | ||
end | ||
end |
Oops, something went wrong.