Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS CLI 二进制输出输出支持 #86

Open
vuhe opened this issue Dec 20, 2024 · 0 comments
Open

macOS CLI 二进制输出输出支持 #86

vuhe opened this issue Dec 20, 2024 · 0 comments

Comments

@vuhe
Copy link

vuhe commented Dec 20, 2024

能否像 libjxl 一样提供二进制输入和输出支持?这样的话可以减少文件写入和读取,也不用关心路径权限的问题了

cjxl 的参数:

JPEG XL encoder v0.11.1 0.11.1 [NEON]
Usage: cjxl INPUT OUTPUT [OPTIONS...]
 INPUT
    the input can be JXL, PPM, PNM, PFM, PAM, PGX, PNG, APNG, GIF, JPEG, EXR
    Use '-' for input from stdin.
 OUTPUT
    the compressed JXL output file
    Use '-' for output to stdout

我使用 python可以批量处理:

def convert_jpeg_to_jxl(jpeg_data):
    """
    Convert JPEG data to JXL using a subprocess for the cjxl command-line tool.
    Returns the JXL binary data.
    """
    try:
        process = subprocess.run(
            ["cjxl", "-", "-"],  # No need for -d 0 for JPEG, as cjxl defaults to lossless for JPEG
            input=jpeg_data,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            check=True
        )
        return process.stdout
    except subprocess.CalledProcessError as e:
        print(f"Error converting JPEG to JXL: {e.stderr.decode()}")
        return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant