# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *
import dataclasses

DJPEG_METADATA = Metadata(
    id="3600c030d01c581f3a3e8577bb83f497b31a9efb.boutiques",
    name="djpeg",
    package="afni",
    container_image_tag="afni/afni_make_build:AFNI_24.2.06",
)


class DjpegOutputs(typing.NamedTuple):
    """
    Output object returned when calling `djpeg(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""
    output_image: OutputPathType
    """Output image file"""


def djpeg(
    input_file: InputPathType,
    output_file: str,
    gray: bool = False,
    fast_dct: bool = False,
    one_pixel_height: bool = False,
    pseudo_pixel_ratio: bool = False,
    crop_region: str | None = None,
    runner: Runner | None = None,
) -> DjpegOutputs:
    """
    Decompress a JPEG file to an image file.
    
    Author: AFNI Developers
    
    URL: https://afni.nimh.nih.gov/
    
    Args:
        input_file: Input JPEG file (e.g. image.jpg).
        output_file: Output image file (e.g. image.ppm).
        gray: Force grayscale output.
        fast_dct: Prevent dithering of output.
        one_pixel_height: Force one-pixel modulation flag.
        pseudo_pixel_ratio: Force pseudo-pixel ratio flag.
        crop_region: Crop region (syntax: WxH+X+Y, e.g., 100x100+10+10).
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `DjpegOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(DJPEG_METADATA)
    cargs = []
    cargs.append("djpeg")
    cargs.append(execution.input_file(input_file))
    cargs.append(output_file)
    if gray:
        cargs.append("-grayscale")
    if fast_dct:
        cargs.append("-fast")
    if one_pixel_height:
        cargs.append("-onepixel")
    if pseudo_pixel_ratio:
        cargs.append("-236")
    if crop_region is not None:
        cargs.extend([
            "-crop",
            crop_region
        ])
    ret = DjpegOutputs(
        root=execution.output_file("."),
        output_image=execution.output_file(output_file),
    )
    execution.run(cargs)
    return ret


__all__ = [
    "DJPEG_METADATA",
    "DjpegOutputs",
    "djpeg",
]
