pwitvoet / wadmaker

Command-line tools for making/extracting Half-Life textures and sprites
28 stars 2 forks source link

(Suggestion) Auto-downscale images to the nearest multiple of 16 values #2

Open DeficientNull opened 1 year ago

DeficientNull commented 1 year ago

The biggest Issue i have when using this tool is how much time i spend figuring out how to get images (from say textures.com) to end up scaled in multiples of 16, i wish this would just automate this process. essentially if an image is 517x261 it will just downscale it to 512z256 by just cropping out the excess.

i don't mind the potential problem of cropping out too much because that's an easy problem to fix that problably won't happen on most textures

pwitvoet commented 1 year ago

There are multiple ways to adjust the size of an image. Basic operations like cropping, padding, scaling, but also more advanced cropping and scaling algorithms that try to preserve the most important parts of an image. All of these have their own benefits and drawbacks: cropping removes potentially important parts of the image, and it breaks tiling. Padding adds possibly unwanted empty space, and it also breaks tiling. Scaling can produce blurry results or introduce other artifacts. In my opinion, which approach works best for any given image is a decision that is best made by a texture artist, not by a tool like WadMaker. So I don't think that adding this is a good idea - certainly not as default behavior.

What you can do however is to use WadMaker's custom converter system to automatically run an image-cropping tool or script for every image. See https://github.com/pwitvoet/wadmaker/blob/master/wadmaker.md#custom-converters for how to configure a custom converter. You could, for example, call a Python script that calculates the new image size, and that uses ImageMagick to crop the image.