1
\$\begingroup\$

I would like to perform bulk operations of a large number of .DDS files (over 100,000) which may appear in any variety of different BCn formats. I would normally use the ImageMagick command line tools for this, however, although it can read BC7 format .DDS files, it does not support writing them back.

Is there a different format which ImageMagick can convert to that I can safely operate on and then recompress back into BC7 with a tool like compressonator?

I am not an expert on the .DDS file format and simply want to optimize their size for my use case. For example, scale all textures which may be 2k, 4k, or 8k all down to 1k to save on VRAM. Can this be done as a bulk operation safely and naively on game assets without accidentally destroying important data in the .DDS file, such as an alpha channel, etc?

\$\endgroup\$
2
  • \$\begingroup\$ DDS is a format that stores date in the same way it would be passed to a GPU. That means it contains things that are most useful at display time, like mipmaps (pre-scaled copies of the image). Do you actually care about preserving things like that from the original? Or would changing the base image and recalculating the mipmaps, etc be desirable? If the latter, I suspect (but don't know for certain) that you could go via tiff. \$\endgroup\$
    – Basic
    Commented Oct 16 at 12:26
  • \$\begingroup\$ As mentioned here, an alternative on Windows is combining a macro app with Paint.net which has .DDS support. You might be able to do a similar thing with Gimp, but I'm not as familiar with that one. \$\endgroup\$
    – Pikalek
    Commented Oct 16 at 14:53

1 Answer 1

0
\$\begingroup\$

My go-to as a safe intermediate format is TGA (Targa), which is supported by both ImageMagick and Compressonator.

This format has uncompressed and lossless compressed modes (run-length encoding, specifically) and supports 8 bits per channel with RGB and optional Alpha. That means any image that a DDS/BCn can store (except BC6H), you can store as a TGA without loss or distortion. (BC6H can store 16 bit floats per channel for HDR colour, which TGA does not support - but if you're just using BC7, that's not an issue)

If your DDS contains mipmaps, you'd need to output each mip as its own TGA, or pack them into one combined image similar to the example from this blog:

Packed Mipmaps

(I'm not familiar enough with ImageMagick to suggest a command to output/recombine mipmaps, so I'll leave that for other answers)

Because of its absent or simplistic compression, TGA files tend to be larger than PNG for example. But many PNG compressors assume that zero-alpha regions are invisible and will alter RGB data in those regions to improve compression. That's not always a safe assumption for game textures, where the alpha channel might not represent opacity but something like a roughness or occlusion map. TGA compressors don't alter RGB data in zero-alpha regions, so they're safer to use as intermediates for these kinds of textures. If you're ultimately compressing back to DDS anyway, the increased size of the intermediate files should not be a major issue.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .