#walkzzz/image.mbt/process/pipeline

    图像处理流水线编排

    #概览

    项目数量
    公开函数11
    公开类型7
    常量0
    错误类型0

    #类型

    pub(all) struct BatchConfig {
    pub struct BatchResult {
    pub struct BatchTask {
    pub(all) enum CliCommand {
    pub(all) enum Operation {
    pub struct Pipeline {
    pub struct ProcessResult {

    #API

    pub fn batch_execute(Array[BatchTask]) -> BatchResult
    pub fn batch_summary(BatchResult) -> String
    pub fn batch_task(String, String, Pipeline) -> BatchTask
    pub fn cli_help() -> String
    pub fn cli_parse(Array[String]) -> CliCommand
    pub fn default_batch_config() -> BatchConfig
    pub fn pipeline_add(Pipeline, Operation) -> Pipeline
    pub fn pipeline_add_all(Pipeline, Array[Operation]) -> Pipeline
    pub fn pipeline_describe(Pipeline) -> String
    pub fn pipeline_len(Pipeline) -> Int
    pub fn pipeline_new() -> Pipeline

    #纯 MoonBit 实现

    本包不依赖任何 C FFI,四目标(native/wasm-gc/js/wasm)均可编译运行。

    BatchConfig

    pub(all) struct BatchConfig {
    input_format : String
    output_format : String
    output_suffix : String
    parallel : Bool
    }

    批处理配置

    BatchResult

    pub struct BatchResult {
    total : Int
    succeeded : Int
    failed : Int
    results : Array[ProcessResult]
    }

    批处理结果

    BatchTask

    pub struct BatchTask {
    input_path : String
    output_path : String
    pipeline : Pipeline
    }

    批处理任务

    CliCommand

    pub(all) enum CliCommand {
    Convert(String, String)
    Resize(String, String, Int, Int)
    Rotate(String, String, Double)
    Batch(String, String, String)
    Info(String)
    Help
    }

    CLI 命令 #non_exhaustive 表示未来可能添加新构造器

    Operation

    pub(all) enum Operation {
    Resize(Int, Int)
    Rotate(Double)
    FlipH
    FlipV
    Grayscale
    Invert
    Blur(Double)
    Sharpen(Double)
    Brightness(Double)
    Contrast(Double)
    Custom(String)
    }

    处理操作类型 #non_exhaustive 表示未来可能添加新构造器

    Pipeline

    pub struct Pipeline {
    operations : Array[Operation]
    }

    流水线(链式操作序列)

    ProcessResult

    pub struct ProcessResult {
    success : Bool
    message : String
    output_size : Int
    }

    处理结果

    batch_execute

    fn batch_execute(tasks : Array[BatchTask]) -> BatchResult

    执行批处理(模拟)

    注意:实际文件 I/O 需要运行时支持,此处提供框架和结果统计。

    batch_summary

    fn batch_summary(result : BatchResult) -> String

    批处理结果摘要

    batch_task

    fn batch_task(input_path : String, output_path : String, pipeline : Pipeline) -> BatchTask

    创建批处理任务

    cli_help

    fn cli_help() -> String

    CLI 帮助文本

    cli_parse

    fn cli_parse(args : Array[String]) -> CliCommand

    CLI 参数解析

    解析命令行参数,返回对应的命令。 支持的命令格式: CLI 命令:convert / resize / rotate / batch / info / help
    • convert 转换格式
    • resize 缩放
    • rotate 旋转
    • batch <input_dir> <output_dir> <pipeline_config> 批处理
    • info 信息
    • help 帮助 解析 Parse command-line arguments, return corresponding command. 描述 Supported command formats: 支持命令:convert / resize / rotate / batch / info / help

    default_batch_config

    fn default_batch_config() -> BatchConfig

    默认批处理配置

    pipeline_add

    fn pipeline_add(p : Pipeline, op : Operation) -> Pipeline

    添加操作到流水线

    pipeline_add_all

    fn pipeline_add_all(p : Pipeline, ops : Array[Operation]) -> Pipeline

    批量添加操作

    pipeline_describe

    fn pipeline_describe(p : Pipeline) -> String

    流水线转字符串描述

    pipeline_len

    fn pipeline_len(p : Pipeline) -> Int

    获取流水线中的操作数量

    pipeline_new

    fn pipeline_new() -> Pipeline

    创建空流水线

    Source Files