forked from EricR/image_sorcery
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EricR#4 from musicglue/graphics_magick
add support for graphics magick with some DCI (guyboertje)
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
module GmSupport | ||
def prefix command | ||
"gm #{command}" | ||
end | ||
end | ||
|
||
class Sorcery | ||
class << self | ||
def gm file | ||
instance = new(file) | ||
instance.extend GmSupport | ||
instance | ||
end | ||
end | ||
end |
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 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,32 @@ | ||
require 'fileutils' | ||
require 'image_sorcery' | ||
|
||
describe "Image Sorcery" do | ||
before :each do | ||
FileUtils.copy "./spec/fixtures/dog.jpeg", "./spec/fixtures/dog-2.jpeg" | ||
@image = Sorcery.gm("./spec/fixtures/dog-2.jpeg") # Who doesn't love dogs? | ||
end | ||
describe "getting the dimensions of an image" do | ||
it "returns a hash of dimensions" do | ||
@image.dimensions.should == {:x => "160", :y => "120"} | ||
end | ||
end | ||
describe "manipulating an image" do | ||
it "resizes an image" do | ||
original_dimensions = @image.dimensions | ||
@image.manipulate!(:resize => "50%") | ||
@image.dimensions.map {|k,v| v.to_i}.should == original_dimensions.map {|k,v| v.to_i/2} | ||
end | ||
end | ||
describe "converting an image" do | ||
it "writes the new image out to a file" do | ||
@image.convert("new_image.png") | ||
File.exists?("new_image.png").should be_true | ||
end | ||
end | ||
describe "identifying an image" do | ||
it "returns a list of layers" do | ||
@image.identify.should include "JPEG 160x120" | ||
end | ||
end | ||
end |