Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
pull_request:
push:
branches:
- master

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.9.0"
cache: npm

- name: Install dependencies
run: npm ci

- name: Lint and test
run: npm test
10 changes: 5 additions & 5 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

// Strict mode.
"use strict";

// Package modules.
const { hideBin } = require("yargs/helpers");
import { hideBin } from "yargs/helpers";

// Local modules.
import sharp from "../lib/index.js";

// Run.
require("../lib")(hideBin(process.argv));
sharp(hideBin(process.argv));
9 changes: 3 additions & 6 deletions cmd/channel-manipulation/bandbool.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

// @see https://sharp.pixelplumbing.com/api-channel#bandbool

// Strict mode.
"use strict";

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -58,7 +55,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "bandbool <operator>",
describe:
"Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image",
Expand Down
7 changes: 2 additions & 5 deletions cmd/channel-manipulation/ensure-alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-channel#ensurealpha

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -62,7 +59,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "ensureAlpha [alpha]",
describe: "Ensure the output image has an alpha transparency channel",
builder,
Expand Down
9 changes: 3 additions & 6 deletions cmd/channel-manipulation/extract-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

// @see https://sharp.pixelplumbing.com/api-channel#extractchannel

// Strict mode.
"use strict";

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -61,7 +58,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "extractChannel <channel>",
describe: "Extract a single channel from a multi-channel image",
builder,
Expand Down
7 changes: 2 additions & 5 deletions cmd/channel-manipulation/join-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-channel#joinchannel

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand All @@ -54,7 +51,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "joinChannel <images..>",
describe: "Join one or more channels to the image",
builder,
Expand Down
9 changes: 3 additions & 6 deletions cmd/channel-manipulation/remove-alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-channel#removealpha

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Command builder.
const builder = (yargs) => {
Expand All @@ -40,11 +37,11 @@ const builder = (yargs) => {
};

// Command handler.
const handler = (args) =>
const handler = () =>
queue.push(["removeAlpha", (sharp) => sharp.removeAlpha()]);

// Exports.
module.exports = {
export default {
command: "removeAlpha",
describe: "Remove alpha channel, if any",
builder,
Expand Down
10 changes: 3 additions & 7 deletions cmd/colour-manipulation/greyscale.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-colour#greyscale

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Command builder.
const builder = (yargs) => {
Expand All @@ -43,11 +40,10 @@ const builder = (yargs) => {
};

// Command handler.
const handler = (args) =>
queue.push(["greyscale", (sharp) => sharp.greyscale()]);
const handler = () => queue.push(["greyscale", (sharp) => sharp.greyscale()]);

// Exports.
module.exports = {
export default {
command: "greyscale",
aliases: "grayscale",
describe: "Convert to 8-bit greyscale; 256 shades of grey",
Expand Down
9 changes: 3 additions & 6 deletions cmd/colour-manipulation/pipeline-colourspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

// @see https://sharp.pixelplumbing.com/api-colour#tocolourspace

// Strict mode.
"use strict";

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -62,7 +59,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "pipelineColourspace <colourspace>",
aliases: "pipelineColorspace",
describe: "Set the pipeline colourspace",
Expand Down
7 changes: 2 additions & 5 deletions cmd/colour-manipulation/tint.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-colour#tint

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand All @@ -52,7 +49,7 @@ const builder = (yargs) => {
const handler = (args) => queue.push(["tint", (sharp) => sharp.tint(args.rgb)]);

// Exports.
module.exports = {
export default {
command: "tint <rgb>",
describe:
"Tint the image using the provided chroma while preserving the image luminance",
Expand Down
9 changes: 3 additions & 6 deletions cmd/colour-manipulation/tocolourspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

// @see https://sharp.pixelplumbing.com/api-colour#tocolourspace

// Strict mode.
"use strict";

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -59,7 +56,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "toColourspace <colourspace>",
aliases: "toColorspace",
describe: "Set the output colourspace",
Expand Down
9 changes: 3 additions & 6 deletions cmd/compositing/composite.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

// @see http://sharp.pixelplumbing.com/api-composite#composite

// Strict mode.
"use strict";

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";

// Helpers.
function getValueAt(arrayLike, index) {
Expand Down Expand Up @@ -206,7 +203,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "composite [images..]",
describe:
"Composite image(s) over the processed (resized, extracted etc.) image",
Expand Down
13 changes: 4 additions & 9 deletions cmd/operations/affine.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@

// @see https://sharp.pixelplumbing.com/api-operation#affine

// Strict mode.
"use strict";

// Package modules.
const pick = require("lodash.pick");

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";
import { pick } from "../../lib/utils.js";

// Configure.
const placeholders = {
Expand Down Expand Up @@ -110,7 +105,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "affine <matrix..>",
describe: "Perform an affine transform on an image",
builder,
Expand Down
7 changes: 2 additions & 5 deletions cmd/operations/blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-operation#blur

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -87,7 +84,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "blur [sigma]",
describe: "Blur the image",
builder,
Expand Down
9 changes: 3 additions & 6 deletions cmd/operations/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

// @see https://sharp.pixelplumbing.com/api-operation#boolean

// Strict mode.
"use strict";

// Local modules.
const constants = require("../../lib/constants");
const queue = require("../../lib/queue");
import constants from "../../lib/constants.js";
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -63,7 +60,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "boolean <operand> <operator>",
describe: "Perform a bitwise boolean operation with operand image",
builder,
Expand Down
7 changes: 2 additions & 5 deletions cmd/operations/clahe.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

// @see https://sharp.pixelplumbing.com/api-operation#clahe

// Strict mode.
"use strict";

// Local modules.
const queue = require("../../lib/queue");
import queue from "../../lib/queue.js";

// Configure.
const positionals = {
Expand Down Expand Up @@ -79,7 +76,7 @@ const handler = (args) => {
};

// Exports.
module.exports = {
export default {
command: "clahe <width> <height>",
describe: "Perform contrast limiting adaptive histogram equalization CLAHE",
builder,
Expand Down
Loading