Batch texture converting. How to convert all images in a directory.
Author: kleskbyLet's say you downloaded a bunch of textures from the internet. Some of them are JPG, some are PNG or even TGA. That is uncomfortable and may cause trouble when importing inside the game. It's good practice to cast all textures to the same format.
To do this, we will need ImageMagick - free open-source software with many pre-build tools.
- Download and install ImageMagick.
- Locate ImageMagick binaries on your computer. In my case it is C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\
- Press Win + R and type cmd or just simply open Command Prompt form Start menu.
- Type
for /r "YOUR TEXTURE FOLDER" %a in (*.*) do "PATH TO IAMGEMAGICK\magick.exe" mogrify -format FORMAT %a - After you press Enter it will start converting process. It may happen that the textures you download appear flipped after converting. In that case add flag -flip after FORMAT.
So your final command will look something like this
for /r "E:\GameDev\TEXTURES" %a in (*.*) do "C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe" mogrify -format png -flip %a - (Optional) To atomize process you may create a bath script. Create an empty text document and type
for /r "YOUR TEXTURE FOLDER" %%a in (*.*) do "PATH TO IAMGEMAGICK\magick.exe" mogrify -format FORMAT %%a
Pay attention that now we have double %%. Save it as .bat script.
Tags: Mapping, 2D, Textures