Update output docs to include tile image format.

Correct some of the JPEG output option type defs.
This commit is contained in:
Lovell Fuller 2016-11-13 20:46:08 +00:00
parent bc84d1e47a
commit dd9d66ef20
5 changed files with 32 additions and 22 deletions

View File

@ -64,11 +64,11 @@ Use these JPEG options for output image.
- `options.quality` **\[[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** quality, integer 1-100 (optional, default `80`) - `options.quality` **\[[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** quality, integer 1-100 (optional, default `80`)
- `options.progressive` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** use progressive (interlace) scan (optional, default `false`) - `options.progressive` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** use progressive (interlace) scan (optional, default `false`)
- `options.chromaSubsampling` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`) - `options.chromaSubsampling` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`)
- `options.trellisQuantisation` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** apply trellis quantisation, requires mozjpeg (optional, default `false`)
- `options.overshootDeringing` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** apply overshoot deringing, requires mozjpeg (optional, default `false`)
- `options.optimiseScans` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** optimise progressive scans, forces progressive, requires mozjpeg (optional, default `false`)
- `options.optimizeScans` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** alternative spelling of optimiseScans (optional, default `false`)
- `options.force` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** force JPEG output, otherwise attempt to use input format (optional, default `true`) - `options.force` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** force JPEG output, otherwise attempt to use input format (optional, default `true`)
- `trellisQuantisation` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** apply trellis quantisation, requires mozjpeg (optional, default `false`)
- `overshootDeringing` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** apply overshoot deringing, requires mozjpeg (optional, default `false`)
- `optimiseScans` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** optimise progressive scans, forces progressive, requires mozjpeg (optional, default `false`)
- `optimizeScans` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** alternative spelling of optimiseScans (optional, default `false`)
- Throws **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid options - Throws **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid options
@ -145,7 +145,8 @@ Returns **Sharp**
# tile # tile
Use tile-based deep zoom (image pyramid) output. Use tile-based deep zoom (image pyramid) output.
You can also use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format. Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.
**Parameters** **Parameters**
@ -159,6 +160,7 @@ You can also use a `.zip` or `.szi` file extension with `toFile` to write to a c
```javascript ```javascript
sharp('input.tiff') sharp('input.tiff')
.png()
.tile({ .tile({
size: 512 size: 512
}) })

View File

@ -26,6 +26,10 @@ Requires libvips v8.4.2.
[#601](https://github.com/lovell/sharp/issues/601) [#601](https://github.com/lovell/sharp/issues/601)
[@dynamite-ready](https://github.com/dynamite-ready) [@dynamite-ready](https://github.com/dynamite-ready)
* Add support for PNG and WebP tile-based output formats (in addition to JPEG).
[#622](https://github.com/lovell/sharp/pull/622)
[@ppaskaris](https://github.com/ppaskaris)
### v0.16 - "*pencil*" ### v0.16 - "*pencil*"
Requires libvips v8.3.3 Requires libvips v8.3.3

View File

@ -88,10 +88,10 @@ const withMetadata = function withMetadata (withMetadata) {
* @param {Number} [options.quality=80] - quality, integer 1-100 * @param {Number} [options.quality=80] - quality, integer 1-100
* @param {Boolean} [options.progressive=false] - use progressive (interlace) scan * @param {Boolean} [options.progressive=false] - use progressive (interlace) scan
* @param {String} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling when quality <= 90 * @param {String} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling when quality <= 90
* @param {Boolean} [trellisQuantisation=false] - apply trellis quantisation, requires mozjpeg * @param {Boolean} [options.trellisQuantisation=false] - apply trellis quantisation, requires mozjpeg
* @param {Boolean} [overshootDeringing=false] - apply overshoot deringing, requires mozjpeg * @param {Boolean} [options.overshootDeringing=false] - apply overshoot deringing, requires mozjpeg
* @param {Boolean} [optimiseScans=false] - optimise progressive scans, forces progressive, requires mozjpeg * @param {Boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive, requires mozjpeg
* @param {Boolean} [optimizeScans=false] - alternative spelling of optimiseScans * @param {Boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans
* @param {Boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format * @param {Boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format
* @returns {Sharp} * @returns {Sharp}
* @throws {Error} Invalid options * @throws {Error} Invalid options
@ -227,10 +227,12 @@ const toFormat = function toFormat (format, options) {
/** /**
* Use tile-based deep zoom (image pyramid) output. * Use tile-based deep zoom (image pyramid) output.
* You can also use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format. * Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
* Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.
* *
* @example * @example
* sharp('input.tiff') * sharp('input.tiff')
* .png()
* .tile({ * .tile({
* size: 512 * size: 512
* }) * })

14
lib/types.d.ts vendored
View File

@ -770,15 +770,15 @@ declare function withMetadata(withMetadata?: { orientation: Number }): Sharp;
* @param {Number} [options.quality=80] - quality, integer 1-100 * @param {Number} [options.quality=80] - quality, integer 1-100
* @param {Boolean} [options.progressive=false] - use progressive (interlace) scan * @param {Boolean} [options.progressive=false] - use progressive (interlace) scan
* @param {String} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling when quality <= 90 * @param {String} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling when quality <= 90
* @param {Boolean} [trellisQuantisation=false] - apply trellis quantisation, requires mozjpeg * @param {Boolean} [options.trellisQuantisation=false] - apply trellis quantisation, requires mozjpeg
* @param {Boolean} [overshootDeringing=false] - apply overshoot deringing, requires mozjpeg * @param {Boolean} [options.overshootDeringing=false] - apply overshoot deringing, requires mozjpeg
* @param {Boolean} [optimiseScans=false] - optimise progressive scans, forces progressive, requires mozjpeg * @param {Boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive, requires mozjpeg
* @param {Boolean} [optimizeScans=false] - alternative spelling of optimiseScans * @param {Boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans
* @param {Boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format * @param {Boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format
* @returns {Sharp} * @returns {Sharp}
* @throws {Error} Invalid options * @throws {Error} Invalid options
*/ */
declare function jpeg(options?: { quality: Number, progressive: Boolean, chromaSubsampling: String, force: Boolean }, trellisQuantisation?: Boolean, overshootDeringing?: Boolean, optimiseScans?: Boolean, optimizeScans?: Boolean): Sharp; declare function jpeg(options?: { quality: Number, progressive: Boolean, chromaSubsampling: String, trellisQuantisation: Boolean, overshootDeringing: Boolean, optimiseScans: Boolean, optimizeScans: Boolean, force: Boolean }): Sharp;
/** /**
* Use these PNG options for output image. * Use these PNG options for output image.
@ -829,10 +829,12 @@ declare function toFormat(format: (String|Object), options: Object): Sharp;
/** /**
* Use tile-based deep zoom (image pyramid) output. * Use tile-based deep zoom (image pyramid) output.
* You can also use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format. * Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
* Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.
* *
* @example * @example
* sharp('input.tiff') * sharp('input.tiff')
* .png()
* .tile({ * .tile({
* size: 512 * size: 512
* }) * })

View File

@ -263,8 +263,8 @@ describe('Tile', function () {
assert.strictEqual(3, metadata.channels); assert.strictEqual(3, metadata.channels);
assert.strictEqual(false, metadata.hasProfile); assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha); assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual(true, metadata.width === 256); assert.strictEqual(256, metadata.width);
assert.strictEqual(true, metadata.height === 256); assert.strictEqual(256, metadata.height);
fs.stat(sample, function (err, stat) { fs.stat(sample, function (err, stat) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, stat.size < 2000); assert.strictEqual(true, stat.size < 2000);
@ -298,8 +298,8 @@ describe('Tile', function () {
assert.strictEqual(3, metadata.channels); assert.strictEqual(3, metadata.channels);
assert.strictEqual(false, metadata.hasProfile); assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha); assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual(true, metadata.width === 256); assert.strictEqual(256, metadata.width);
assert.strictEqual(true, metadata.height === 256); assert.strictEqual(256, metadata.height);
fs.stat(sample, function (err, stat) { fs.stat(sample, function (err, stat) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, stat.size > 44000); assert.strictEqual(true, stat.size > 44000);
@ -333,8 +333,8 @@ describe('Tile', function () {
assert.strictEqual(3, metadata.channels); assert.strictEqual(3, metadata.channels);
assert.strictEqual(false, metadata.hasProfile); assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha); assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual(true, metadata.width === 256); assert.strictEqual(256, metadata.width);
assert.strictEqual(true, metadata.height === 256); assert.strictEqual(256, metadata.height);
fs.stat(sample, function (err, stat) { fs.stat(sample, function (err, stat) {
if (err) throw err; if (err) throw err;
assert.strictEqual(true, stat.size < 2000); assert.strictEqual(true, stat.size < 2000);