Merge branch 'dev'

main
Andrew Cassidy 10 months ago
commit 3280fc74be

@ -9,15 +9,32 @@ comparable to the original library.
## Installation
To install, first clone this repo and cd into it, then run:
### From Wheel (Easiest)
To install, run
```shell
pip install quicktex
```
If you are on macOS, You need to install openMP from homebrew:
```shell
brew install libomp
```
### From Source
To build from source, first clone this repo and cd into it, then run:
```shell
git submodule update --init
pip install .
```
and setuptools will take care of any dependencies for you.
If you are on macOS, it is recommended to first install openMP from homebrew to enable
If you are on macOS, it is recommended to first install openMP from homebrew to enable
multithreading, since it is not included in the default Apple Clang install:
```shell
@ -31,8 +48,6 @@ required dependencies for them, install with options like so:
pip install .[tests,stubs,docs]
```
Quicktex will be available on Pypi once it is out of alpha.
## Usage
```

@ -46,7 +46,7 @@ docs = [
stubs = ["pybind11-stubgen"]
[project.urls]
Docs = "https://quicktex.readthedocs.io/en/"
Docs = "https://quicktex.readthedocs.io/en/latest/"
Source = "https://github.com/drewcassidy/quicktex"
Changelog = "https://github.com/drewcassidy/quicktex/blob/main/CHANGELOG.md"

@ -40,7 +40,7 @@ def path_pairs(inputs, output, suffix, extension):
"""
if len(inputs) < 1:
raise click.BadArgumentUsage('No input files were provided.')
raise click.BadArgumentUsage('No valid input files were provided.')
inpaths = [pathlib.Path(i) for i in inputs]

@ -36,7 +36,8 @@ def encode():
help="Output file or directory. If outputting to a file, input filenames must be only a single item. By default, files are decoded in place.",
)
@click.argument('filenames', nargs=-1, type=click.Path(exists=True, readable=True, dir_okay=False))
def encode_format(encoder, four_cc, flip, remove, suffix, output, filenames):
def encode_format(encoder, four_cc, flip, remove, suffix, output, filenames, swizzle=False):
filenames = [f for f in filenames if not f.endswith('.dds')]
path_pairs = common.path_pairs(filenames, output, suffix, '.dds')
with click.progressbar(
@ -48,6 +49,11 @@ def encode_format(encoder, four_cc, flip, remove, suffix, output, filenames):
if flip:
image = image.transpose(Image.FLIP_TOP_BOTTOM)
if swizzle:
bands = image.split()
one = Image.new('L', image.size, 0xFF)
image = Image.merge('RGBA', (one, bands[1], bands[1], bands[0]))
dds.encode(image, encoder, four_cc).save(outpath)
if remove:
@ -107,8 +113,11 @@ def encode_auto(level, black, threecolor, flip, remove, suffix, output, filename
bc1_encoder = quicktex.s3tc.bc1.BC1Encoder(level, mode)
bc3_encoder = quicktex.s3tc.bc3.BC3Encoder(level)
filenames = [f for f in filenames if not f.endswith('.dds')]
path_pairs = common.path_pairs(filenames, output, suffix, '.dds')
assert len(filenames) > 0
with click.progressbar(
path_pairs, show_eta=False, show_pos=True, item_show_func=lambda x: str(x[0]) if x else ''
) as bar:
@ -175,9 +184,16 @@ def encode_bc1(level, black, threecolor, **kwargs):
default=18,
help='Quality level to use. Higher values = higher quality, but slower.',
)
def encode_bc3(level, **kwargs):
@click.option(
'-n/-N',
'--normal/--no-normal',
type=bool,
default=False,
help='Perform a BC3nm swizzle, copying the red channel into the alpha [default: no-normal]',
)
def encode_bc3(level, normal, **kwargs):
"""Encode images to BC4 (RGBA, 8-bit interpolated alpha)."""
encode_format.callback(quicktex.s3tc.bc3.BC3Encoder(level), 'DXT5', **kwargs)
encode_format.callback(quicktex.s3tc.bc3.BC3Encoder(level), 'DXT5', swizzle=normal, **kwargs)
@click.command('bc4')

Loading…
Cancel
Save