@doufunao123/asset-gateway 0.10.0 → 0.11.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/dist/index.js +1 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -754,27 +754,7 @@ function saveProcessOutput(data, outputDir) {
|
|
|
754
754
|
return filePath;
|
|
755
755
|
}
|
|
756
756
|
function createProcessCommand() {
|
|
757
|
-
const command = new Command5("process").description("Post-process images (
|
|
758
|
-
command.addCommand(
|
|
759
|
-
new Command5("remove-bg").description("Remove background from an image (AI-powered, BiRefNet)").requiredOption("--input <path>", "Input image (file path or URL)").option("--smart-crop", "Also crop to power-of-2 after removing background").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
760
|
-
try {
|
|
761
|
-
const ctx = createContext(this);
|
|
762
|
-
const ops = [{ op: "remove_bg" }];
|
|
763
|
-
if (options.smartCrop) {
|
|
764
|
-
ops.push({ op: "smart_crop", mode: "power_of2" });
|
|
765
|
-
}
|
|
766
|
-
const data = await ctx.client.post("/api/process", {
|
|
767
|
-
input: readInputAsBase64(options.input),
|
|
768
|
-
operations: ops
|
|
769
|
-
});
|
|
770
|
-
const localPath = saveProcessOutput(data, options.outputDir);
|
|
771
|
-
if (localPath) data.local_path = localPath;
|
|
772
|
-
printSuccess("process.remove-bg", data, ctx);
|
|
773
|
-
} catch (error2) {
|
|
774
|
-
printError("process.remove-bg", error2);
|
|
775
|
-
}
|
|
776
|
-
})
|
|
777
|
-
);
|
|
757
|
+
const command = new Command5("process").description("Post-process images (crop, resize)");
|
|
778
758
|
command.addCommand(
|
|
779
759
|
new Command5("crop").description("Smart crop an image (trim transparent borders)").requiredOption("--input <path>", "Input image (file path or URL)").option("--mode <mode>", "Crop mode: tightest or power_of2", "tightest").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
780
760
|
try {
|
|
@@ -807,22 +787,6 @@ function createProcessCommand() {
|
|
|
807
787
|
}
|
|
808
788
|
})
|
|
809
789
|
);
|
|
810
|
-
command.addCommand(
|
|
811
|
-
new Command5("upscale").description("AI upscale an image (2x or 4x via Real-ESRGAN)").requiredOption("--input <path>", "Input image (file path or URL)").option("--scale <n>", "Scale factor (2 or 4)", "4").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
812
|
-
try {
|
|
813
|
-
const ctx = createContext(this);
|
|
814
|
-
const data = await ctx.client.post("/api/process", {
|
|
815
|
-
input: readInputAsBase64(options.input),
|
|
816
|
-
operations: [{ op: "upscale", scale: Number(options.scale) }]
|
|
817
|
-
});
|
|
818
|
-
const localPath = saveProcessOutput(data, options.outputDir);
|
|
819
|
-
if (localPath) data.local_path = localPath;
|
|
820
|
-
printSuccess("process.upscale", data, ctx);
|
|
821
|
-
} catch (error2) {
|
|
822
|
-
printError("process.upscale", error2);
|
|
823
|
-
}
|
|
824
|
-
})
|
|
825
|
-
);
|
|
826
790
|
return command;
|
|
827
791
|
}
|
|
828
792
|
|