Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds CLI options for finer control of input resampling #280

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rsms
Copy link

@rsms rsms commented Jan 16, 2022

First off, thank you for this lovely software!

This patch adds four command-line options to the encoder tool for increased control of input preprocessing resampling:

  • -resample_filter X Set resample filter kernel, default is box, filters: box, tent, bell, blackman, catmullrom, mitchell, etc.
  • -resample_filter_scale X Set resample filter kernel's scale, lower=sharper, higher=more blurry, default is 1.0
  • -resample_ifgt Only resample if the image is larger than width or height provided with -resample
  • -resample_aspect Keep aspect ratio of image while resampling. "fit" the image inside the -resample rectangle

I've tried my best to match the style of the existing code and have of course tested all this with a bunch of different inputs.

Examples

Resample inputs using lanczos3 filter with a 0.8 scale factor:

basisu -resample 512 512 -resample_filter lanczos3 -resample_filter_scale 0.8 a.png

Resample inputs to fit within 512x512, maintaining their aspect ratio:

basisu -resample 512 512 -resample_aspect a.png

Resample inputs only if the width is larger than 1024 or if the height is larger than 512:

basisu -resample 1024 512 -resample_ifgt a.png

@richgel999
Copy link
Contributor

This is great - I will merge this into latest.

@richgel999 richgel999 added the enhancement New feature or request label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants