Skip to content

grandwo/ctex2png

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CTEX to PNG Converter

中文 | Chinese

English | 英文

项目介绍

这是一个用于将 CTEX 文件转换为 PNG 图像的 Python 工具,支持单文件转换和目录批量转换。

背景说明

在解包游戏文件时发现似乎没有现成的工具可以批量将 CTEX 文件转为 PNG,于是借助 AI 完成了这段代码。

功能说明

CTEX 文件中包含嵌入的 DDS(DirectDraw Surface)图像数据。该工具会提取 DDS 数据并将其转换为 PNG 格式。

安装

  1. 确保已安装 Python 3.14+。
  2. 安装依赖:
    uv sync

使用方法

单文件转换

将单个 .ctex 文件转为 PNG:

uv run python main.py <input.ctex> <output.png>

或者指定一个输出目录(会自动生成输出文件名):

uv run python main.py <input.ctex> <output_directory>

批量目录转换

将目录中的所有 .ctex 文件转换为 PNG:

uv run python main.py <input_directory> <output_directory>
  • input:指向 .ctex 文件或包含 .ctex 文件的目录
  • output:当输入为文件时为输出 PNG 文件路径;当输入为目录时为输出目录路径

示例:

# 单文件
uv run python main.py example.ctex output.png
uv run python main.py example.ctex ./output_dir

# 批量
uv run python main.py ./ctex_files ./output_png

依赖项

  • Pillow(通过 uv sync 自动安装)

备注

  • 仅处理扩展名为 .ctex 的文件
  • 如果文件中未找到 RIFF 数据,将跳过该文件并输出警告
  • 若输出目录不存在,会自动创建
  • 将单个文件输出到目录时,输出文件名会根据输入文件名生成

introduction

A Python tool to convert CTEX files to PNG images, supporting both single-file conversion and batch directory processing.

Background

This tool was created during game file unpacking. I found there was no obvious tool to batch convert CTEX to PNG, so I used AI to complete the code.

Description

CTEX files contain DDS (DirectDraw Surface) image data embedded in a binary format. This tool extracts the DDS data and converts it to PNG format.

Installation

  1. Ensure you have Python 3.14+ installed.
  2. Install dependencies:
    uv sync

Usage

Single File Conversion

Convert a single .ctex file to PNG:

uv run python main.py <input.ctex> <output.png>

Or specify an output directory (filename will be auto-generated):

uv run python main.py <input.ctex> <output_directory>

Batch Directory Conversion

Convert all .ctex files in a directory:

uv run python main.py <input_directory> <output_directory>
  • input: Path to a .ctex file or directory containing .ctex files
  • output: Path to output PNG file (when input is a file) or directory (when input is a directory)

Examples:

# Single file
uv run python main.py example.ctex output.png
uv run python main.py example.ctex ./output_dir

# Batch
uv run python main.py ./ctex_files ./output_png

Requirements

  • Pillow (automatically installed via uv sync)

Notes

  • Only files with .ctex extension are processed
  • If no RIFF data is found in a file, it will be skipped with a warning
  • Output directory will be created if it doesn't exist
  • When converting a single file to a directory, the output filename is derived from the input filename

About

.ctex 文件批量转 PNG 工具 | CTEX to PNG Converter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages