-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
161 additions
and
2 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
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,16 @@ | ||
/** | ||
* Example for using LWIP to cover a canvas with an image. | ||
*/ | ||
|
||
var path = require('path'), | ||
lwip = require('../'); | ||
|
||
lwip.open('lena.jpg', function(err, image) { | ||
if (err) return console.log(err); | ||
image.cover(400,800,function(err, image){ | ||
image.writeFile('lena_cover.jpg', function(err){ | ||
if (err) return console.log(err); | ||
console.log('done'); | ||
}); | ||
}); | ||
}); |
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
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,61 @@ | ||
var join = require('path').join, | ||
should = require('should'), | ||
assert = require('assert'), | ||
mkdirp = require('mkdirp'), | ||
lwip = require('../../'), | ||
imgs = require('../imgs'); | ||
|
||
var tmpDir = join(__dirname, '../results'), | ||
basename = 'cover', | ||
current; | ||
|
||
describe('lwip.cover', function() { | ||
|
||
var image; | ||
|
||
before(function(done) { | ||
mkdirp(tmpDir, done); | ||
}); | ||
|
||
beforeEach(function(done) { | ||
lwip.open(imgs.png.rgb, function(err, img) { | ||
image = img; | ||
done(err); | ||
}); | ||
}); | ||
|
||
afterEach(function(done) { | ||
image.writeFile(join(tmpDir, current.join('_') + '.jpg'), 'jpg', { | ||
quality: 90 | ||
}, done); | ||
}); | ||
|
||
beforeEach(function(){ | ||
current = [ basename ]; | ||
}); | ||
|
||
describe('800X300, unspecified interpolation', function() { | ||
it('image should have the correct size', function(done) { | ||
current.push('800X300','unspecified_inter'); | ||
image.cover(800, 300, function(err, im) { | ||
if (err) return done(err); | ||
assert(im.width() === 800); | ||
assert(im.height() === 300); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('300X800, lanczos interpolation', function() { | ||
it('image should have the correct size', function(done) { | ||
current.push('300X800','lanczos'); | ||
image.cover(300, 800, 'lanczos', function(err, im) { | ||
if (err) return done(err); | ||
assert(im.width() === 300); | ||
assert(im.height() === 800); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
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
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