Jump to content

Quicktex DDS texture encoder/decoder


Recommended Posts

Quicktex

Available on Github

License: LGPL

Quicktex is a python library and command line tool for encoding and decoding DDS files. It is based on the RGBCX encoder, which is currently one of the highest quality S3TC encoders available. Quicktex has a python front end, but the encoding and decoding is all done in C++ for speed comparable to the original library.  While it is not only useful for KSP,  KSP is what I initially made it for, so I think it can go here for support and visibility. It should have higher quality than NVTT or DDS4KSP, while still being reasonably fast, as well as having a (in development, unstable) python API for custom scripting and tricky image types like light cookies.

Installation

If you are on macOS, you need to first install openMP from homebrew to enable multithreading, since it is not included in the default Apple Clang install:

brew install libomp

To install, just install from PyPI using pip (the package manager built into python)

pip install quicktex

and setuptools will take care of any python dependencies for you.

 

The package also makes tests, stub generation, and docs available. To install the required dependencies for them, install with options like so (Docs are still a work in progress):

pip install quicktex[tests,stubs,docs]

Quicktex will be available on Pypi once it is out of alpha.

Usage

Usage: quicktex [OPTIONS] COMMAND [ARGS]...

  Encode and Decode various image formats

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  decode  Decode DDS files to images.
  encode  Encode images to DDS files of the given format.

To decode DDS files to images, use the decode subdommand, along with a glob or a list of files to decode.

To encode images to DDS files, use the encode subcommand, plus an additional subcommand for the format. For example, quicktex encode bc1 bun.png will encode bun.png in the current directory to a bc1/DXT1 dds file next to it. 

For KSP textures I recommend quicktex encode auto -r [filenames]

encode and decode both accept several common parameters:

  • -f, --flip / -F, --no-flip: Vertically flip image before/after converting. [default: True]
  • -r, --remove: Remove input images after converting.
  • -s, --suffix TEXT: Suffix to append to output filename(s). Ignored if output is a single file.
  • -o, --output: Output file or directory. If outputting to a file, input filenames must be only a single item. By default, files are converted in place.
Edited by cineboxandrew
better install instructions
Link to comment
Share on other sites

Posted (edited)

Pillow-mbm

To go with Quicktex, I created a python module for converting MBM files, also available on github as well as pypi

License: AGPL

Installation

To install from Pypi, run:

pip install pillow-mbm

Usage

To decode MBM files, use the convert-mbm command, along with a glob or a list of files to decode. By default, it will convert to png in place.

Usage: convert-mbm [OPTIONS] [FILENAMES]...

  Decode Kerbal Space Program MBM files

Options:
  -f, --flip / -F, --no-flip  Vertically flip image after converting.
  -r, --remove                Remove input images after converting.
  -s, --suffix TEXT           Suffix to append to output file(s). Ignored if
                              output is a single file.

  -x, --extension TEXT        Extension to use for output. Ignored if output
                              is a single file. Output filetype is deduced
                              from this  [default: .png]

  -o, --output PATH           Output file or directory. If outputting to a
                              file, input filenames must be only a single
                              item. By default, files are decoded in place.

  --version                   Show the version and exit.
  --help                      Show this message and exit.
Edited by cineboxandrew
Link to comment
Share on other sites

I was pretty excited to try this out, but thought I may have an utterly borked python install on my windows machine and I'm getting yet-un-figured-out errors.  I also got an error trying the pip install on my mac about being unable to checkout '[large string]' in submodule path 'tests/images' -- could that be a hiccup I was experiencing on the Win10 attempt as well?

Curious if anyone else got this to install cleanly.

All this does it make me want to figure out how to tidy up/understand all those python installations before it starts to look like that XKCD comic.

Link to comment
Share on other sites

Posted (edited)
2 hours ago, Beetlecat said:

  I also got an error trying the pip install on my mac about being unable to checkout '[large string]' in submodule path 'tests/images' -- could that be a hiccup I was experiencing on the Win10 attempt as well?

Try it again now, I didnt realize having test images in a submodule would cause issues. Not sure how to help with your windows issues though

Edited by cineboxandrew
Link to comment
Share on other sites

11 hours ago, cineboxandrew said:

Try it again now, I didnt realize having test images in a submodule would cause issues. Not sure how to help with your windows issues though

The windows issues are *all* my own to sort out... ;)

Link to comment
Share on other sites

  • 4 weeks later...
Posted (edited)

Quicktex is now on PyPI, so you can now install it with just

pip install quicktex

Prebuilt packages are available for mac, linux, and windows on x86_64. If you're on ARM you'll have to make sure you have a C/C++ compiler installed so pip can build quicktex from source, at least until github actions has ARM support.

Edited by cineboxandrew
Link to comment
Share on other sites

11 hours ago, cineboxandrew said:

Quicktex is now on PyPI, so you can now install it with just

pip install quicktex

Prebuilt packages are available for mac, linux, and windows on x86_64. If you're on ARM you'll have to make sure you have a C/C++ compiler installed so pip can build quicktex from source, at least until github actions has ARM support.

And there was much rejoicing. ;D

Thanks for the further update. This will be sure to save *some* frustration, I'm sure.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...