Skip to content

Commit

Permalink
Update to sharp 0.18.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark van Seventer authored and Mark van Seventer committed Jun 26, 2017
1 parent 1a93de1 commit a18515d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.4.0 (June 26, 2017)
> https://github.com/vseventer/sharp-cli/compare/v1.3.0...v1.4.0
* Added [`--squash`](http://sharp.dimens.io/en/stable/api-output/#tiff)
(`sharp` 0.18.0).
* Updated `fs-extra`, `mocha`, `nyc`, `sharp`, `sinon`, `snazzy`, `standard`,
and `yargs` dependencies.

## 1.3.0 (April 3, 2017)
> https://github.com/vseventer/sharp-cli/compare/v1.2.0...v1.3.0
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Optimization Options
--overshootDeringing Apply overshoot deringing [boolean]
--sequentialRead An advanced setting that switches the libvips access method to
VIPS_ACCESS_SEQUENTIAL [boolean]
--squash Squash 8-bit images down to 1 bit [boolean]
--trellisQuantisation Apply trellis quantisation [boolean]
Misc. Options
Expand Down
12 changes: 10 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ const options = {
type: 'boolean'
},

// @see http://sharp.dimens.io/en/stable/api-output/#tiff
squash: {
desc: 'Squash 8-bit images down to 1 bit',
group: optimize,
type: 'boolean'
},

// @see http://sharp.dimens.io/en/stable/api-output/#jpeg
trellisQuantisation: {
desc: 'Apply trellis quantisation',
Expand Down Expand Up @@ -339,13 +346,14 @@ cli.parse = (argv, context, callback) => {
// @see http://sharp.dimens.io/en/stable/api-output/#tiff
if (args.compression !== options.compression.default ||
args.predictor !== options.predictor.default ||
args.quality) {
args.quality || args.squash) {
queue.unshift([ 'tiff', (sharp) => {
return sharp.tiff({
compression: args.compression,
force: false,
predictor: args.predictor,
quality: args.quality
quality: args.quality,
squash: args.squash
})
}])
}
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
BOOL: Object.keys(sharp.bool),
COLOURSPACE: Object.keys(sharp.colourspace),
CONTAINER: [ 'fs', 'zip' ],
FORMAT: [ 'jpeg', 'png', 'raw', 'tiff', 'webp' ],
FORMAT: [ 'jpeg', 'jpg', 'png', 'raw', 'tiff', 'webp' ],
GRAVITY: Object.keys(sharp.gravity),
INTERPOLATOR: Object.keys(sharp.interpolator),
KERNEL: Object.keys(sharp.kernel),
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "sharp-cli",
"version" : "1.3.0",
"version" : "1.4.0",
"description" : "CLI for sharp.",
"keywords" : [ "cli", "jpeg", "libvips", "png", "sharp", "vips", "webp" ],
"homepage" : "https://github.com/vseventer/sharp-cli",
Expand All @@ -18,18 +18,18 @@
"dependencies": {
"bubble-stream-error": "1.0.x",
"multiyargs" : "1.0.x",
"sharp" : "0.17.x",
"sharp" : "0.18.1",
"url-template" : "2.0.x",
"yargs" : "7.0.x"
"yargs" : "8.0.x"
},
"devDependencies": {
"fs-extra" : "2.1.x",
"mocha" : "3.2.x",
"fs-extra" : "3.0.x",
"mocha" : "3.4.x",
"must" : "0.13.x",
"nyc" : "10.2.x",
"sinon" : "2.1.x",
"snazzy" : "6.0.x",
"standard" : "9.0.x",
"nyc" : "11.0.x",
"sinon" : "2.3.x",
"snazzy" : "7.0.x",
"standard" : "10.0.x",
"tempfile" : "2.0.x"
},
"engines": { "node": ">=6.x" }
Expand Down
18 changes: 18 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,24 @@ describe(`${pkg.name} <options> [command..]`, () => {
})
})

describe('--squash', () => {
// Run.
beforeEach((done) => cli.parse([ '--squash', ...ioFlags ], done))

// Tests.
it('must set the squash flag', () => {
expect(cli.parsed.argv).to.have.property('squash', true)
})
it('must update the pipeline', () => {
expect(queue.pipeline).to.have.length(1)
expect(queue.pipeline).to.include('tiff')
})
it('must execute the pipeline', () => {
const pipeline = queue.drain(sharp())
sinon.assert.calledWithMatch(pipeline.tiff, { squash: true })
})
})

describe('--trellisQuantisation', () => {
// Run.
beforeEach((done) => cli.parse([ '--trellisQuantisation', ...ioFlags ], done))
Expand Down

0 comments on commit a18515d

Please sign in to comment.