# joy_BatchToTGA

## What it is for
`joy_BatchToTGA.py` batch-converts source images into `.tga` files that are ready to drop into a Kingpin workflow.

It is especially handy when:
- converting an entire game's texture set for use in Kingpin
- converting a large folder of pictures or source textures
- normalizing names and formats before import into a mod or mapping project

## Why this version is useful
Compared with a very basic converter, this script does more of the annoying cleanup work automatically:
- accepts several common image formats
- can detect companion alpha-mask files
- automatically writes 32-bit TGA when real alpha is needed
- ignores fully white alpha masks instead of forcing useless transparency
- can lowercase filenames and replace spaces
- includes a `--kingpin` preset for common Kingpin-friendly output settings

## Supported input formats
- `.png`
- `.jpg`
- `.jpeg`
- `.pcx`
- `.tga`
- `.bmp`

## Companion alpha masks
The script can look for separate mask files using suffixes like:
- `_a`
- `_alpha`
- ` a`
- ` alpha`
- `mask`

Example:
- `brick.png`
- `brick_a.png`

## Basic usage
```bat
python joy_BatchToTGA.py [input_folder] [output_folder] [options]
```

## Recommended Kingpin-oriented usage
```bat
python joy_BatchToTGA.py textures output --kingpin
```

The `--kingpin` preset sets:
- 24-bit output by default
- compression on
- alpha support on
- darkening on
- lowercase filenames
- spaces replaced with underscores

## Arguments
- `input_folder`  
  Optional input folder. Defaults to the current directory.

- `output_folder`  
  Optional output folder. Defaults to the input folder.

- `--bit-depth {24,32}`  
  Requested output bit depth.

- `--no-alpha`  
  Disables alpha output.

- `--no-compression`  
  Disables TGA compression.

- `--darken`  
  Darkens the image by 50%.

- `--scale FLOAT`  
  Resizes the image by a scale factor.

- `--scaletype {bilinear,bicubic,nearest}`  
  Resampling method used when scaling.

- `--allowuppercase`  
  Keeps uppercase letters in output filenames.

- `--allowspace`  
  Keeps spaces in output filenames.

- `--kingpin`  
  Applies the built-in Kingpin preset.

## Example
Convert an entire folder of textures at half size using the preset:

```bat
python joy_BatchToTGA.py C:\source_textures C:\kingpin_textures --kingpin --scale 0.5
```

## Output
The script writes `.tga` files to the output folder and skips files that appear to be standalone alpha masks.

## Notes
If you are converting a large batch of textures for immediate Kingpin use, this is one of the more useful tools in the set.
