mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Compare commits
13 Commits
dependabot
...
0.2.1
Author | SHA1 | Date | |
---|---|---|---|
a05c1e352e | |||
1f7aad7218 | |||
23133eb802 | |||
0448dbe6e1 | |||
ec7953dcff | |||
3280fc74be | |||
cbec93ed55 | |||
8509384bff | |||
1c86b09ca0 | |||
d4eada16f9 | |||
aed575edc6 | |||
4cdcb65f3a | |||
b81df96990 |
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@ -7,4 +7,10 @@ updates:
|
|||||||
target-branch: "dev"
|
target-branch: "dev"
|
||||||
schedule:
|
schedule:
|
||||||
# Check for updates to GitHub Actions every weekday
|
# Check for updates to GitHub Actions every weekday
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
|
||||||
|
# Maintain dependencies for pip
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
24
.github/workflows/python-package.yml
vendored
24
.github/workflows/python-package.yml
vendored
@ -45,15 +45,13 @@ jobs:
|
|||||||
path: dist/*.tar.gz
|
path: dist/*.tar.gz
|
||||||
|
|
||||||
build-wheels:
|
build-wheels:
|
||||||
name: Build Wheels on ${{ matrix.os }} ${{ matrix.arch[0] }}
|
name: Build Wheels on ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ macos-11, windows-latest, ubuntu-latest ]
|
# macos-13 is an intel runner, macos-14 is apple silicon
|
||||||
arch: [ ['x86', 'x86_64', 'AMD64', 'x86_64' ] ] #[suffix, mac, windows, linux] arch names
|
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
|
||||||
include:
|
linux_arch: [ 'x86_64' ] #[suffix, mac, windows, linux] arch names
|
||||||
- os: ubuntu-latest
|
|
||||||
arch: [ 'ARM', 'arm64', 'ARM64', 'aarch64' ]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -71,17 +69,19 @@ jobs:
|
|||||||
sudo tar fvxz openmp-*.tar.gz -C /
|
sudo tar fvxz openmp-*.tar.gz -C /
|
||||||
|
|
||||||
- name: Install QEMU
|
- name: Install QEMU
|
||||||
# install QEMU if building for arm linux
|
# install QEMU if building for linux
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
if: runner.os == 'linux' && matrix.arch[3] == 'aarch64'
|
if: runner.os == 'linux'
|
||||||
with:
|
with:
|
||||||
platforms: arm64
|
platforms: arm64
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: pypa/cibuildwheel@v2.11.2
|
uses: pypa/cibuildwheel@v2.18.1
|
||||||
env:
|
env:
|
||||||
MACOSX_DEPLOYMENT_TARGET: "10.15"
|
MACOSX_DEPLOYMENT_TARGET: "12"
|
||||||
CIBW_ARCHS_LINUX: ${{ matrix.arch[3] }}
|
CIBW_ARCHS_LINUX: 'x86_64 aarch64'
|
||||||
|
CIBW_ARCHS_MACOS: 'native'
|
||||||
|
CIBW_SKIP: 'cp37*'
|
||||||
|
|
||||||
- name: Upload Wheels
|
- name: Upload Wheels
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@ -139,4 +139,4 @@ jobs:
|
|||||||
name: ${{ env.VERSION_TITLE }}
|
name: ${{ env.VERSION_TITLE }}
|
||||||
body_path: RELEASE.md
|
body_path: RELEASE.md
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
24
CHANGELOG.md
24
CHANGELOG.md
@ -2,11 +2,33 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file
|
All notable changes to this project will be documented in this file
|
||||||
|
|
||||||
## Unreleased
|
## 0.2.1 - 2024-06-03
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed broken transparency on palettized PNG files
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Changed which wheels are built by the CI. There are no changes to OS or Python version compatibility if you compile from source.
|
||||||
|
- Stopped building Python 3.7 wheels
|
||||||
|
- Stopped building macOS universal wheels
|
||||||
|
- Wheels for macOS now require macOS 12 or later
|
||||||
|
- Included macOS ARM wheels
|
||||||
|
- Included Python 3.12 wheels
|
||||||
|
|
||||||
|
|
||||||
|
## 0.2.0 - 2023-06-21
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Updated Pybind11 to version 3.10, adding Python 3.11 support
|
- Updated Pybind11 to version 3.10, adding Python 3.11 support
|
||||||
|
- Updated install instructions in readme to reflect availability on PyPI
|
||||||
|
- Encode now skips .dds files in its input to prevent needless re-encoding
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added the `-n` option for bc3 encoding to perform a BC3nm swizzle
|
||||||
|
|
||||||
|
|
||||||
## 0.1.3 - 2022-04-13
|
## 0.1.3 - 2022-04-13
|
||||||
|
23
README.md
23
README.md
@ -9,15 +9,32 @@ comparable to the original library.
|
|||||||
|
|
||||||
## Installation
|
## 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
|
```shell
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
pip install .
|
pip install .
|
||||||
```
|
```
|
||||||
|
|
||||||
and setuptools will take care of any dependencies for you.
|
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:
|
multithreading, since it is not included in the default Apple Clang install:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@ -31,8 +48,6 @@ required dependencies for them, install with options like so:
|
|||||||
pip install .[tests,stubs,docs]
|
pip install .[tests,stubs,docs]
|
||||||
```
|
```
|
||||||
|
|
||||||
Quicktex will be available on Pypi once it is out of alpha.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -46,7 +46,7 @@ docs = [
|
|||||||
stubs = ["pybind11-stubgen"]
|
stubs = ["pybind11-stubgen"]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Docs = "https://quicktex.readthedocs.io/en/"
|
Docs = "https://quicktex.readthedocs.io/en/latest/"
|
||||||
Source = "https://github.com/drewcassidy/quicktex"
|
Source = "https://github.com/drewcassidy/quicktex"
|
||||||
Changelog = "https://github.com/drewcassidy/quicktex/blob/main/CHANGELOG.md"
|
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:
|
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]
|
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.",
|
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))
|
@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')
|
path_pairs = common.path_pairs(filenames, output, suffix, '.dds')
|
||||||
|
|
||||||
with click.progressbar(
|
with click.progressbar(
|
||||||
@ -48,6 +49,11 @@ def encode_format(encoder, four_cc, flip, remove, suffix, output, filenames):
|
|||||||
if flip:
|
if flip:
|
||||||
image = image.transpose(Image.FLIP_TOP_BOTTOM)
|
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)
|
dds.encode(image, encoder, four_cc).save(outpath)
|
||||||
|
|
||||||
if remove:
|
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)
|
bc1_encoder = quicktex.s3tc.bc1.BC1Encoder(level, mode)
|
||||||
bc3_encoder = quicktex.s3tc.bc3.BC3Encoder(level)
|
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')
|
path_pairs = common.path_pairs(filenames, output, suffix, '.dds')
|
||||||
|
|
||||||
|
assert len(filenames) > 0
|
||||||
|
|
||||||
with click.progressbar(
|
with click.progressbar(
|
||||||
path_pairs, show_eta=False, show_pos=True, item_show_func=lambda x: str(x[0]) if x else ''
|
path_pairs, show_eta=False, show_pos=True, item_show_func=lambda x: str(x[0]) if x else ''
|
||||||
) as bar:
|
) as bar:
|
||||||
@ -175,9 +184,16 @@ def encode_bc1(level, black, threecolor, **kwargs):
|
|||||||
default=18,
|
default=18,
|
||||||
help='Quality level to use. Higher values = higher quality, but slower.',
|
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 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')
|
@click.command('bc4')
|
||||||
|
@ -275,6 +275,7 @@ def read(path: os.PathLike) -> DDSFile:
|
|||||||
def encode(image: Image.Image, encoder, four_cc: str, mip_count: typing.Optional[int] = None) -> DDSFile:
|
def encode(image: Image.Image, encoder, four_cc: str, mip_count: typing.Optional[int] = None) -> DDSFile:
|
||||||
if image.mode != 'RGBA' or image.mode != 'RGBX':
|
if image.mode != 'RGBA' or image.mode != 'RGBX':
|
||||||
mode = 'RGBA' if 'A' in image.mode else 'RGBX'
|
mode = 'RGBA' if 'A' in image.mode else 'RGBX'
|
||||||
|
image.apply_transparency() # why is this necessary what
|
||||||
image = image.convert(mode)
|
image = image.convert(mode)
|
||||||
|
|
||||||
sizes = quicktex.image_utils.mip_sizes(image.size, mip_count)
|
sizes = quicktex.image_utils.mip_sizes(image.size, mip_count)
|
||||||
|
Reference in New Issue
Block a user