@mediaproc/image 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +529 -67
- package/dist/cli.js +22 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/affine.d.ts +3 -0
- package/dist/commands/affine.d.ts.map +1 -0
- package/dist/commands/affine.js +154 -0
- package/dist/commands/affine.js.map +1 -0
- package/dist/commands/auto-orient.d.ts +3 -0
- package/dist/commands/auto-orient.d.ts.map +1 -0
- package/dist/commands/auto-orient.js +106 -0
- package/dist/commands/auto-orient.js.map +1 -0
- package/dist/commands/boolean.d.ts +3 -0
- package/dist/commands/boolean.d.ts.map +1 -0
- package/dist/commands/boolean.js +153 -0
- package/dist/commands/boolean.js.map +1 -0
- package/dist/commands/dilate.d.ts +3 -0
- package/dist/commands/dilate.d.ts.map +1 -0
- package/dist/commands/dilate.js +139 -0
- package/dist/commands/dilate.js.map +1 -0
- package/dist/commands/erode.d.ts +3 -0
- package/dist/commands/erode.d.ts.map +1 -0
- package/dist/commands/erode.js +139 -0
- package/dist/commands/erode.js.map +1 -0
- package/dist/commands/flatten.d.ts +3 -0
- package/dist/commands/flatten.d.ts.map +1 -0
- package/dist/commands/flatten.js +130 -0
- package/dist/commands/flatten.js.map +1 -0
- package/dist/commands/flop.d.ts +3 -0
- package/dist/commands/flop.d.ts.map +1 -0
- package/dist/commands/flop.js +87 -0
- package/dist/commands/flop.js.map +1 -0
- package/dist/commands/linear.d.ts +3 -0
- package/dist/commands/linear.d.ts.map +1 -0
- package/dist/commands/linear.js +133 -0
- package/dist/commands/linear.js.map +1 -0
- package/dist/commands/recomb.d.ts +3 -0
- package/dist/commands/recomb.d.ts.map +1 -0
- package/dist/commands/recomb.js +146 -0
- package/dist/commands/recomb.js.map +1 -0
- package/dist/commands/threshold.d.ts +3 -0
- package/dist/commands/threshold.d.ts.map +1 -0
- package/dist/commands/threshold.js +126 -0
- package/dist/commands/threshold.js.map +1 -0
- package/dist/commands/unflatten.d.ts +3 -0
- package/dist/commands/unflatten.d.ts.map +1 -0
- package/dist/commands/unflatten.js +105 -0
- package/dist/commands/unflatten.js.map +1 -0
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +22 -0
- package/dist/register.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { createSharpInstance } from '../utils/sharp.js';
|
|
6
|
+
import { createStandardHelp } from '../utils/helpFormatter.js';
|
|
7
|
+
export function dilateCommand(imageCmd) {
|
|
8
|
+
const cmd = imageCmd
|
|
9
|
+
.command('dilate <input>')
|
|
10
|
+
.description('Dilate image (expand bright regions)')
|
|
11
|
+
.option('-o, --output <path>', 'Output file path')
|
|
12
|
+
.option('-q, --quality <quality>', 'Quality (1-100)', parseInt, 90)
|
|
13
|
+
.option('--dry-run', 'Show what would be done without executing')
|
|
14
|
+
.option('-v, --verbose', 'Verbose output');
|
|
15
|
+
cmd.addHelpText('after', () => {
|
|
16
|
+
createStandardHelp({
|
|
17
|
+
commandName: 'dilate',
|
|
18
|
+
emoji: '⚪',
|
|
19
|
+
description: 'Apply morphological dilation to expand bright regions and fill gaps. Useful for closing holes and connecting nearby objects.',
|
|
20
|
+
usage: ['dilate <input>', 'dilate <input> -o dilated.png'],
|
|
21
|
+
options: [
|
|
22
|
+
{ flag: '-o, --output <path>', description: 'Output file path (default: <input>-dilated.<ext>)' },
|
|
23
|
+
{ flag: '-q, --quality <quality>', description: 'Output quality 1-100 (default: 90)' },
|
|
24
|
+
{ flag: '--dry-run', description: 'Preview changes without executing' },
|
|
25
|
+
{ flag: '-v, --verbose', description: 'Show detailed output' }
|
|
26
|
+
],
|
|
27
|
+
examples: [
|
|
28
|
+
{ command: 'dilate mask.png', description: 'Expand white regions in mask' },
|
|
29
|
+
{ command: 'dilate document.jpg -o filled.jpg', description: 'Fill small gaps' },
|
|
30
|
+
{ command: 'dilate binary.png --verbose', description: 'Connect nearby objects' }
|
|
31
|
+
],
|
|
32
|
+
additionalSections: [
|
|
33
|
+
{
|
|
34
|
+
title: 'What is Dilation?',
|
|
35
|
+
items: [
|
|
36
|
+
'Morphological operation from image processing',
|
|
37
|
+
'Expands bright (high-value) regions',
|
|
38
|
+
'Shrinks dark (low-value) regions',
|
|
39
|
+
'Opposite of erosion',
|
|
40
|
+
'Uses 3x3 kernel by default'
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'Use Cases',
|
|
45
|
+
items: [
|
|
46
|
+
'Fill small holes/gaps in objects',
|
|
47
|
+
'Connect nearby components',
|
|
48
|
+
'Expand boundaries of objects',
|
|
49
|
+
'Remove small dark noise',
|
|
50
|
+
'Strengthen weak edges'
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: 'Common Workflows',
|
|
55
|
+
items: [
|
|
56
|
+
'Hole filling: dilate → erode (closing)',
|
|
57
|
+
'Edge detection: subtract original from dilated',
|
|
58
|
+
'Object joining: multiple dilations',
|
|
59
|
+
'Mask expansion for compositing',
|
|
60
|
+
'Feature enhancement in binary images'
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: 'Tips',
|
|
65
|
+
items: [
|
|
66
|
+
'Works best on binary or high-contrast images',
|
|
67
|
+
'Multiple dilations = stronger effect',
|
|
68
|
+
'Combine with erode for morphological closing',
|
|
69
|
+
'Useful before filling/connecting operations'
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
tips: [
|
|
74
|
+
'Opposite effect of erode command',
|
|
75
|
+
'Use on binary/grayscale images',
|
|
76
|
+
'Apply multiple times for stronger effect',
|
|
77
|
+
'Useful for connecting nearby objects'
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
return '';
|
|
81
|
+
});
|
|
82
|
+
cmd.action(async (input, options) => {
|
|
83
|
+
const spinner = ora('Processing image...').start();
|
|
84
|
+
try {
|
|
85
|
+
if (!fs.existsSync(input)) {
|
|
86
|
+
spinner.fail(chalk.red(`Input file not found: ${input}`));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
const inputPath = path.parse(input);
|
|
90
|
+
const outputPath = options.output || path.join(process.cwd(), `${inputPath.name}-dilated${inputPath.ext}`);
|
|
91
|
+
if (options.verbose) {
|
|
92
|
+
spinner.info(chalk.blue('Configuration:'));
|
|
93
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
94
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
95
|
+
console.log(chalk.dim(` Operation: Morphological dilation (3x3 kernel)`));
|
|
96
|
+
spinner.start('Processing...');
|
|
97
|
+
}
|
|
98
|
+
if (options.dryRun) {
|
|
99
|
+
spinner.info(chalk.yellow('Dry run mode - no changes will be made'));
|
|
100
|
+
console.log(chalk.green('✓ Would apply dilation:'));
|
|
101
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
102
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const metadata = await createSharpInstance(input).metadata();
|
|
106
|
+
// Create a 3x3 dilation kernel (all ones)
|
|
107
|
+
const dilationKernel = {
|
|
108
|
+
width: 3,
|
|
109
|
+
height: 3,
|
|
110
|
+
kernel: [1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
111
|
+
};
|
|
112
|
+
const pipeline = createSharpInstance(input).convolve(dilationKernel);
|
|
113
|
+
const outputExt = path.extname(outputPath).toLowerCase();
|
|
114
|
+
if (outputExt === '.jpg' || outputExt === '.jpeg') {
|
|
115
|
+
pipeline.jpeg({ quality: options.quality || 90 });
|
|
116
|
+
}
|
|
117
|
+
else if (outputExt === '.png') {
|
|
118
|
+
pipeline.png({ quality: options.quality || 90 });
|
|
119
|
+
}
|
|
120
|
+
else if (outputExt === '.webp') {
|
|
121
|
+
pipeline.webp({ quality: options.quality || 90 });
|
|
122
|
+
}
|
|
123
|
+
await pipeline.toFile(outputPath);
|
|
124
|
+
const outputStats = fs.statSync(outputPath);
|
|
125
|
+
spinner.succeed(chalk.green('✓ Dilation applied successfully!'));
|
|
126
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
127
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
128
|
+
console.log(chalk.dim(` Size: ${metadata.width}x${metadata.height}`));
|
|
129
|
+
console.log(chalk.dim(` File size: ${(outputStats.size / 1024).toFixed(2)} KB`));
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
spinner.fail(chalk.red('Failed to apply dilation'));
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
134
|
+
console.error(chalk.red(errorMessage));
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=dilate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dilate.js","sourceRoot":"","sources":["../../src/commands/dilate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,MAAM,UAAU,aAAa,CAAC,QAAiB;IAC3C,MAAM,GAAG,GAAG,QAAQ;SACf,OAAO,CAAC,gBAAgB,CAAC;SACzB,WAAW,CAAC,sCAAsC,CAAC;SACnD,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;SACjD,MAAM,CAAC,yBAAyB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE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,CAAC;YAC5E,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erode.d.ts","sourceRoot":"","sources":["../../src/commands/erode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA6IpD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { createSharpInstance } from '../utils/sharp.js';
|
|
6
|
+
import { createStandardHelp } from '../utils/helpFormatter.js';
|
|
7
|
+
export function erodeCommand(imageCmd) {
|
|
8
|
+
const cmd = imageCmd
|
|
9
|
+
.command('erode <input>')
|
|
10
|
+
.description('Erode image (expand dark regions)')
|
|
11
|
+
.option('-o, --output <path>', 'Output file path')
|
|
12
|
+
.option('-q, --quality <quality>', 'Quality (1-100)', parseInt, 90)
|
|
13
|
+
.option('--dry-run', 'Show what would be done without executing')
|
|
14
|
+
.option('-v, --verbose', 'Verbose output');
|
|
15
|
+
cmd.addHelpText('after', () => {
|
|
16
|
+
return '\n' +
|
|
17
|
+
createStandardHelp({
|
|
18
|
+
commandName: 'erode',
|
|
19
|
+
emoji: '⚫',
|
|
20
|
+
description: 'Apply morphological erosion to expand dark regions and shrink bright areas. Useful for removing noise and separating objects.',
|
|
21
|
+
usage: ['erode <input>', 'erode <input> -o eroded.png'],
|
|
22
|
+
options: [
|
|
23
|
+
{ flag: '-o, --output <path>', description: 'Output file path (default: <input>-eroded.<ext>)' },
|
|
24
|
+
{ flag: '-q, --quality <quality>', description: 'Output quality 1-100 (default: 90)' },
|
|
25
|
+
{ flag: '--dry-run', description: 'Preview changes without executing' },
|
|
26
|
+
{ flag: '-v, --verbose', description: 'Show detailed output' }
|
|
27
|
+
],
|
|
28
|
+
examples: [
|
|
29
|
+
{ command: 'erode mask.png', description: 'Erode binary mask' },
|
|
30
|
+
{ command: 'erode document.jpg -o clean.jpg', description: 'Remove small bright spots' },
|
|
31
|
+
{ command: 'erode text.png --verbose', description: 'Thin text with details' }
|
|
32
|
+
],
|
|
33
|
+
additionalSections: [
|
|
34
|
+
{
|
|
35
|
+
title: 'What is Erosion?',
|
|
36
|
+
items: [
|
|
37
|
+
'Morphological operation from image processing',
|
|
38
|
+
'Expands dark (low-value) regions',
|
|
39
|
+
'Shrinks bright (high-value) regions',
|
|
40
|
+
'Opposite of dilation',
|
|
41
|
+
'Uses 3x3 kernel by default'
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: 'Use Cases',
|
|
46
|
+
items: [
|
|
47
|
+
'Remove small bright noise/spots',
|
|
48
|
+
'Separate touching objects',
|
|
49
|
+
'Thin bright features (text, lines)',
|
|
50
|
+
'Create borders around objects',
|
|
51
|
+
'Clean up binary masks'
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Common Workflows',
|
|
56
|
+
items: [
|
|
57
|
+
'Noise removal: erode → dilate (opening)',
|
|
58
|
+
'Edge detection: subtract eroded from original',
|
|
59
|
+
'Object separation: multiple erosions',
|
|
60
|
+
'Text processing: thin characters',
|
|
61
|
+
'Mask refinement in image segmentation'
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: 'Tips',
|
|
66
|
+
items: [
|
|
67
|
+
'Works best on binary or high-contrast images',
|
|
68
|
+
'Multiple erosions = stronger effect',
|
|
69
|
+
'Combine with dilate for morphological opening',
|
|
70
|
+
'Useful before object counting/separation'
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
tips: [
|
|
75
|
+
'Opposite effect of dilate command',
|
|
76
|
+
'Use on binary/grayscale images',
|
|
77
|
+
'Apply multiple times for stronger effect',
|
|
78
|
+
'Useful for separating connected objects'
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
cmd.action(async (input, options) => {
|
|
83
|
+
const spinner = ora('Processing image...').start();
|
|
84
|
+
try {
|
|
85
|
+
if (!fs.existsSync(input)) {
|
|
86
|
+
spinner.fail(chalk.red(`Input file not found: ${input}`));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
const inputPath = path.parse(input);
|
|
90
|
+
const outputPath = options.output || path.join(process.cwd(), `${inputPath.name}-eroded${inputPath.ext}`);
|
|
91
|
+
if (options.verbose) {
|
|
92
|
+
spinner.info(chalk.blue('Configuration:'));
|
|
93
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
94
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
95
|
+
console.log(chalk.dim(` Operation: Morphological erosion (3x3 kernel)`));
|
|
96
|
+
spinner.start('Processing...');
|
|
97
|
+
}
|
|
98
|
+
if (options.dryRun) {
|
|
99
|
+
spinner.info(chalk.yellow('Dry run mode - no changes will be made'));
|
|
100
|
+
console.log(chalk.green('✓ Would apply erosion:'));
|
|
101
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
102
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const metadata = await createSharpInstance(input).metadata();
|
|
106
|
+
// Erosion kernel (3x3 matrix with all values set to -1 for erosion effect)
|
|
107
|
+
const erodeKernel = {
|
|
108
|
+
width: 3,
|
|
109
|
+
height: 3,
|
|
110
|
+
kernel: [-1, -1, -1, -1, 8, -1, -1, -1, -1]
|
|
111
|
+
};
|
|
112
|
+
const pipeline = createSharpInstance(input).convolve(erodeKernel);
|
|
113
|
+
const outputExt = path.extname(outputPath).toLowerCase();
|
|
114
|
+
if (outputExt === '.jpg' || outputExt === '.jpeg') {
|
|
115
|
+
pipeline.jpeg({ quality: options.quality || 90 });
|
|
116
|
+
}
|
|
117
|
+
else if (outputExt === '.png') {
|
|
118
|
+
pipeline.png({ quality: options.quality || 90 });
|
|
119
|
+
}
|
|
120
|
+
else if (outputExt === '.webp') {
|
|
121
|
+
pipeline.webp({ quality: options.quality || 90 });
|
|
122
|
+
}
|
|
123
|
+
await pipeline.toFile(outputPath);
|
|
124
|
+
const outputStats = fs.statSync(outputPath);
|
|
125
|
+
spinner.succeed(chalk.green('✓ Erosion applied successfully!'));
|
|
126
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
127
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
128
|
+
console.log(chalk.dim(` Size: ${metadata.width}x${metadata.height}`));
|
|
129
|
+
console.log(chalk.dim(` File size: ${(outputStats.size / 1024).toFixed(2)} KB`));
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
spinner.fail(chalk.red('Failed to apply erosion'));
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
134
|
+
console.error(chalk.red(errorMessage));
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=erode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erode.js","sourceRoot":"","sources":["../../src/commands/erode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,MAAM,UAAU,YAAY,CAAC,QAAiB;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CAAC,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;YACnD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../src/commands/flatten.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAazC,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAqItD"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { createSharpInstance } from '../utils/sharp.js';
|
|
6
|
+
import { createStandardHelp } from '../utils/helpFormatter.js';
|
|
7
|
+
export function flattenCommand(imageCmd) {
|
|
8
|
+
const cmd = imageCmd
|
|
9
|
+
.command('flatten <input>')
|
|
10
|
+
.description('Flatten alpha transparency onto background color')
|
|
11
|
+
.option('--background <color>', 'Background color as hex (default: #ffffff)', '#ffffff')
|
|
12
|
+
.option('-o, --output <path>', 'Output file path')
|
|
13
|
+
.option('-q, --quality <quality>', 'Quality (1-100)', parseInt, 90)
|
|
14
|
+
.option('--dry-run', 'Show what would be done without executing')
|
|
15
|
+
.option('-v, --verbose', 'Verbose output');
|
|
16
|
+
cmd.addHelpText('after', () => {
|
|
17
|
+
return '\n' + createStandardHelp({
|
|
18
|
+
commandName: 'flatten',
|
|
19
|
+
emoji: '🎨',
|
|
20
|
+
description: 'Remove alpha channel by merging transparency onto a solid background color. Essential for converting PNGs with transparency to JPEGs.',
|
|
21
|
+
usage: ['flatten <input>', 'flatten <input> --background #ff0000'],
|
|
22
|
+
options: [
|
|
23
|
+
{ flag: '--background <color>', description: 'Background color as hex (default: #ffffff white)' },
|
|
24
|
+
{ flag: '-o, --output <path>', description: 'Output file path (default: <input>-flat.<ext>)' },
|
|
25
|
+
{ flag: '-q, --quality <quality>', description: 'Output quality 1-100 (default: 90)' },
|
|
26
|
+
{ flag: '--dry-run', description: 'Preview changes without executing' },
|
|
27
|
+
{ flag: '-v, --verbose', description: 'Show detailed output' }
|
|
28
|
+
],
|
|
29
|
+
examples: [
|
|
30
|
+
{ command: 'flatten logo.png', description: 'Flatten onto white background' },
|
|
31
|
+
{ command: 'flatten image.png --background #000000', description: 'Flatten onto black' },
|
|
32
|
+
{ command: 'flatten graphic.png --background #ff0000 -o red-bg.jpg', description: 'Flatten onto red and save as JPG' }
|
|
33
|
+
],
|
|
34
|
+
additionalSections: [
|
|
35
|
+
{
|
|
36
|
+
title: 'Use Cases',
|
|
37
|
+
items: [
|
|
38
|
+
'Convert PNG with transparency to JPEG',
|
|
39
|
+
'Prepare images for platforms that don\'t support transparency',
|
|
40
|
+
'Composite transparent images onto colored backgrounds',
|
|
41
|
+
'Remove alpha channel to reduce file size'
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: 'Color Formats',
|
|
46
|
+
items: [
|
|
47
|
+
'#ffffff - White (default)',
|
|
48
|
+
'#000000 - Black',
|
|
49
|
+
'#ff0000 - Red',
|
|
50
|
+
'#00ff00 - Green',
|
|
51
|
+
'#0000ff - Blue',
|
|
52
|
+
'Use 6-digit hex format'
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
tips: [
|
|
57
|
+
'Required when converting PNG to JPEG',
|
|
58
|
+
'White background is default',
|
|
59
|
+
'Choose background color that matches your design',
|
|
60
|
+
'Flattened images have smaller file sizes'
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
cmd.action(async (input, options) => {
|
|
65
|
+
const spinner = ora('Processing image...').start();
|
|
66
|
+
try {
|
|
67
|
+
if (!fs.existsSync(input)) {
|
|
68
|
+
spinner.fail(chalk.red(`Input file not found: ${input}`));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
// Parse background color
|
|
72
|
+
const bgColor = options.background || '#ffffff';
|
|
73
|
+
const bgHex = bgColor.replace('#', '');
|
|
74
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(bgHex)) {
|
|
75
|
+
spinner.fail(chalk.red('Invalid background color format. Use 6-digit hex like #ffffff'));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const r = parseInt(bgHex.substring(0, 2), 16);
|
|
79
|
+
const g = parseInt(bgHex.substring(2, 4), 16);
|
|
80
|
+
const b = parseInt(bgHex.substring(4, 6), 16);
|
|
81
|
+
const inputPath = path.parse(input);
|
|
82
|
+
const outputPath = options.output || path.join(process.cwd(), `${inputPath.name}-flat${inputPath.ext}`);
|
|
83
|
+
if (options.verbose) {
|
|
84
|
+
spinner.info(chalk.blue('Configuration:'));
|
|
85
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
86
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
87
|
+
console.log(chalk.dim(` Background: ${bgColor} (R:${r}, G:${g}, B:${b})`));
|
|
88
|
+
spinner.start('Processing...');
|
|
89
|
+
}
|
|
90
|
+
if (options.dryRun) {
|
|
91
|
+
spinner.info(chalk.yellow('Dry run mode - no changes will be made'));
|
|
92
|
+
console.log(chalk.green('✓ Would flatten image:'));
|
|
93
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
94
|
+
console.log(chalk.dim(` Background: ${bgColor}`));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const metadata = await createSharpInstance(input).metadata();
|
|
98
|
+
const pipeline = createSharpInstance(input).flatten({
|
|
99
|
+
background: { r, g, b }
|
|
100
|
+
});
|
|
101
|
+
const outputExt = path.extname(outputPath).toLowerCase();
|
|
102
|
+
if (outputExt === '.jpg' || outputExt === '.jpeg') {
|
|
103
|
+
pipeline.jpeg({ quality: options.quality || 90 });
|
|
104
|
+
}
|
|
105
|
+
else if (outputExt === '.png') {
|
|
106
|
+
pipeline.png({ quality: options.quality || 90 });
|
|
107
|
+
}
|
|
108
|
+
else if (outputExt === '.webp') {
|
|
109
|
+
pipeline.webp({ quality: options.quality || 90 });
|
|
110
|
+
}
|
|
111
|
+
await pipeline.toFile(outputPath);
|
|
112
|
+
const inputStats = fs.statSync(input);
|
|
113
|
+
const outputStats = fs.statSync(outputPath);
|
|
114
|
+
const sizeDiff = ((outputStats.size - inputStats.size) / inputStats.size * 100).toFixed(2);
|
|
115
|
+
spinner.succeed(chalk.green('✓ Image flattened successfully!'));
|
|
116
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
117
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
118
|
+
console.log(chalk.dim(` Background: ${bgColor}`));
|
|
119
|
+
console.log(chalk.dim(` Size: ${metadata.width}x${metadata.height}`));
|
|
120
|
+
console.log(chalk.dim(` File size: ${(outputStats.size / 1024).toFixed(2)} KB (${sizeDiff}%)`));
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
spinner.fail(chalk.red('Failed to flatten image'));
|
|
124
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
125
|
+
console.error(chalk.red(errorMessage));
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.js","sourceRoot":"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AC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flop.d.ts","sourceRoot":"","sources":["../../src/commands/flop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAuFnD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { createSharpInstance } from '../utils/sharp.js';
|
|
6
|
+
import { createStandardHelp } from '../utils/helpFormatter.js';
|
|
7
|
+
export function flopCommand(imageCmd) {
|
|
8
|
+
const cmd = imageCmd
|
|
9
|
+
.command('flop <input>')
|
|
10
|
+
.description('Flip image horizontally (mirror left-right)')
|
|
11
|
+
.option('-o, --output <path>', 'Output file path')
|
|
12
|
+
.option('-q, --quality <quality>', 'Quality (1-100)', parseInt, 90)
|
|
13
|
+
.option('--dry-run', 'Show what would be done without executing')
|
|
14
|
+
.option('-v, --verbose', 'Verbose output');
|
|
15
|
+
cmd.addHelpText('after', () => {
|
|
16
|
+
return '\n' + createStandardHelp({
|
|
17
|
+
commandName: 'flop',
|
|
18
|
+
emoji: '🔄',
|
|
19
|
+
description: 'Flip image horizontally (mirror left-right). Standalone horizontal flip operation from Sharp.',
|
|
20
|
+
usage: ['flop <input>', 'flop <input> -o output.jpg'],
|
|
21
|
+
options: [
|
|
22
|
+
{ flag: '-o, --output <path>', description: 'Output file path (default: <input>-flopped.<ext>)' },
|
|
23
|
+
{ flag: '-q, --quality <quality>', description: 'Output quality 1-100 (default: 90)' },
|
|
24
|
+
{ flag: '--dry-run', description: 'Preview changes without executing' },
|
|
25
|
+
{ flag: '-v, --verbose', description: 'Show detailed output' }
|
|
26
|
+
],
|
|
27
|
+
examples: [
|
|
28
|
+
{ command: 'flop photo.jpg', description: 'Flip image horizontally' },
|
|
29
|
+
{ command: 'flop selfie.jpg -o corrected.jpg', description: 'Correct selfie mirror effect' }
|
|
30
|
+
],
|
|
31
|
+
tips: [
|
|
32
|
+
'Use flip command for vertical flipping',
|
|
33
|
+
'Combine with other transforms in batch operations'
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
cmd.action(async (input, options) => {
|
|
38
|
+
const spinner = ora('Processing image...').start();
|
|
39
|
+
try {
|
|
40
|
+
if (!fs.existsSync(input)) {
|
|
41
|
+
spinner.fail(chalk.red(`Input file not found: ${input}`));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const inputPath = path.parse(input);
|
|
45
|
+
const outputPath = options.output || path.join(process.cwd(), `${inputPath.name}-flopped${inputPath.ext}`);
|
|
46
|
+
if (options.verbose) {
|
|
47
|
+
spinner.info(chalk.blue('Configuration:'));
|
|
48
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
49
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
50
|
+
spinner.start('Processing...');
|
|
51
|
+
}
|
|
52
|
+
if (options.dryRun) {
|
|
53
|
+
spinner.info(chalk.yellow('Dry run mode - no changes will be made'));
|
|
54
|
+
console.log(chalk.green('✓ Would flop image:'));
|
|
55
|
+
console.log(chalk.dim(` From: ${input}`));
|
|
56
|
+
console.log(chalk.dim(` To: ${outputPath}`));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const metadata = await createSharpInstance(input).metadata();
|
|
60
|
+
const pipeline = createSharpInstance(input).flop();
|
|
61
|
+
const outputExt = path.extname(outputPath).toLowerCase();
|
|
62
|
+
if (outputExt === '.jpg' || outputExt === '.jpeg') {
|
|
63
|
+
pipeline.jpeg({ quality: options.quality || 90 });
|
|
64
|
+
}
|
|
65
|
+
else if (outputExt === '.png') {
|
|
66
|
+
pipeline.png({ quality: options.quality || 90 });
|
|
67
|
+
}
|
|
68
|
+
else if (outputExt === '.webp') {
|
|
69
|
+
pipeline.webp({ quality: options.quality || 90 });
|
|
70
|
+
}
|
|
71
|
+
await pipeline.toFile(outputPath);
|
|
72
|
+
const outputStats = fs.statSync(outputPath);
|
|
73
|
+
spinner.succeed(chalk.green('✓ Image flopped successfully!'));
|
|
74
|
+
console.log(chalk.dim(` Input: ${input}`));
|
|
75
|
+
console.log(chalk.dim(` Output: ${outputPath}`));
|
|
76
|
+
console.log(chalk.dim(` Size: ${metadata.width}x${metadata.height}`));
|
|
77
|
+
console.log(chalk.dim(` File size: ${(outputStats.size / 1024).toFixed(2)} KB`));
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
spinner.fail(chalk.red('Failed to flop image'));
|
|
81
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82
|
+
console.error(chalk.red(errorMessage));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=flop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flop.js","sourceRoot":"","sources":["../../src/commands/flop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,MAAM,UAAU,WAAW,CAAC,QAA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