Skip to content

Commit

Permalink
Add support for Sharp 0.14.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
vseventer committed Apr 18, 2016
1 parent 04504b0 commit a482ba3
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.4.1 (April 18, 2016)
* Enhancement: add [`--tileContainer`](http://sharp.dimens.io/en/stable/api/#tileoptions).

## 0.4.0 (April 4, 2016)
* Enhancement: add [`--extend`](http://sharp.dimens.io/en/stable/api/#extendextension) support.
* Enhancement: add [`--overlayGravity`](http://sharp.dimens.io/en/stable/api/#overlaywithimage-options) support.
Expand Down
7 changes: 7 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ var cli = meow(help, {
'blur',
'compressionLevel',
'crop',
'extendBottom',
'extendLeft',
'extendRight',
'extendTop',
'extractHeight',
'extractLeft',
'extractTop',
Expand All @@ -82,6 +86,7 @@ var cli = meow(help, {
'limitInputPixels',
'output',
'overlay',
'overlayGravity',
'progressive',
'quality',
'rotate',
Expand All @@ -90,6 +95,8 @@ var cli = meow(help, {
'sharpenJagged',
'threshold',
'tile',
'tileContainer',
'tileLayout',
'tileOverlap',
'width'
],
Expand Down
1 change: 1 addition & 0 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Options
--threshold <number> Specify the level above which pixels will be forced to white.
--tile [number] Applies square image pyramid tiles over the image, optionally
specifying a tile size between 1 and 8192. Defaults to 256 pixels.
--tileContainer <string> Specifies the tile container (fs, zip). Defaults to fs.
--tileLayout <string> Specifies the layout to use when generating square Deep Zoom image
pyramid tyles (dz, zoomify, google). Defaults to dz.
Use in conjunction with --tile.
Expand Down
2 changes: 1 addition & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ var run = function(src, flags) {

// @see http://sharp.dimens.io/en/stable/api/#tilesize-overlap
if(flags.tile) {
var options = { layout: flags.tileLayout };
var options = { container: flags.tileContainer, layout: flags.tileLayout };
if(true !== flags.tile) {
options.size = parseInt(flags.tile, 10);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "sharp-cli",
"version" : "0.4.0",
"version" : "0.4.1",
"description" : "CLI for sharp.",
"keywords" : [ "cli", "jpeg", "libvips", "png", "sharp", "vips", "webp" ],
"homepage" : "https://github.com/vseventer/sharp-cli",
Expand Down
Binary file modified test/fixtures/input.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 29 additions & 7 deletions test/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,15 +844,15 @@ describe('runner', function() {
this.flags.tile = true;
return runner.run(input, this.flags).then(function() {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { layout: undefined } ]);
expect(spy.args[0]).to.eql([ { container: undefined, layout: undefined } ]);
});
});
it('--tile [number]', function() {
var spy = this.spyOn('tile');
this.flags.tile = '128';
return runner.run(input, this.flags).then(function() {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { size: 128, layout: undefined } ]);
expect(spy.args[0]).to.eql([ { size: 128, container: undefined, layout: undefined } ]);
});
});
it('--tile [number] (invalid value)', function() {
Expand All @@ -862,18 +862,40 @@ describe('runner', function() {
throw new Error('TRIGGER REJECTION');
}).catch(function(err) {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { size: NaN, layout: undefined } ]);
expect(spy.args[0]).to.eql([ { size: NaN, container: undefined, layout: undefined } ]);
expect(err).to.have.property('message');
expect(err.message.toLowerCase()).to.contain('invalid tile size');
});
});
it('--tileContainer <string>', function() {
var spy = this.spyOn('tile');
this.flags.tile = true;
this.flags.tileContainer = 'fs';
return runner.run(input, this.flags).then(function() {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { container: 'fs', layout: undefined } ]);
});
});
it('--tileContainer <string> (invalid value)', function() {
var spy = this.spyOn('tile');
this.flags.tile = true;
this.flags.tileContainer = 'foo';
return runner.run(input, this.flags).then(function() {
throw new Error('TRIGGER REJECTION');
}).catch(function(err) {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { container: 'foo', layout: undefined } ]);
expect(err).to.have.property('message');
expect(err.message.toLowerCase()).to.contain('invalid tile container');
});
});
it('--tileLayout <string>', function() {
var spy = this.spyOn('tile');
this.flags.tile = true;
this.flags.tileLayout = 'google';
return runner.run(input, this.flags).then(function() {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { layout: 'google' } ]);
expect(spy.args[0]).to.eql([ { container: undefined, layout: 'google' } ]);
});
});
it('--tileLayout <string> (invalid value)', function() {
Expand All @@ -884,7 +906,7 @@ describe('runner', function() {
throw new Error('TRIGGER REJECTION');
}).catch(function(err) {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { layout: 'foo' } ]);
expect(spy.args[0]).to.eql([ { container: undefined, layout: 'foo' } ]);
expect(err).to.have.property('message');
expect(err.message.toLowerCase()).to.contain('invalid tile layout');
});
Expand All @@ -895,7 +917,7 @@ describe('runner', function() {
this.flags.tileOverlap = '32';
return runner.run(input, this.flags).then(function() {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { overlap: 32, layout: undefined } ]);
expect(spy.args[0]).to.eql([ { overlap: 32, container: undefined, layout: undefined } ]);
});
});
it('--tileOverlap <number> (invalid value)', function() {
Expand All @@ -906,7 +928,7 @@ describe('runner', function() {
throw new Error('TRIGGER REJECTION');
}).catch(function(err) {
expect(spy).to.be.calledOnce;
expect(spy.args[0]).to.eql([ { overlap: NaN, layout: undefined } ]);
expect(spy.args[0]).to.eql([ { overlap: NaN, container: undefined, layout: undefined } ]);
expect(err).to.have.property('message');
expect(err.message.toLowerCase()).to.contain('invalid tile overlap');
});
Expand Down

0 comments on commit a482ba3

Please sign in to comment.