Reputation: 315
I'm having some difficulty using the ImageMagick command line utility to properly convert a png to a DDS file with the DXT5 compression algorithm.
convert -format dds -define dds:compression=dxt5 leia.png leia.dds
This was done using Version: ImageMagick 6.8.9-10 Q16 x86_64 2016-09-14
. I am able to view the file locally, so it appears correct. When I load it into OpenGL however, I just see artifacts all over the place (random color pixels). To confirm the generated file was a DDS file:
od -bc leia.dds | head
Which generated:
$ od -bc leia.dds | head
0000000 104 104 123 040 174 000 000 000 007 020 010 000 356 002 000 000
D D S | \0 \0 \0 \a 020 \b \0 356 002 \0 \0
0000020 024 003 000 000 120 014 000 000 000 000 000 000 001 000 000 000
024 003 \0 \0 P \f \0 \0 \0 \0 \0 \0 001 \0 \0 \0
0000040 111 115 101 107 105 115 101 107 111 103 113 000 000 000 000 000
I M A G E M A G I C K \0 \0 \0 \0 \0
0000060 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000100 000 000 000 000 000 000 000 000 000 000 000 000 040 000 000 000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
You can see the first part of the header which contains the DDS
header.
So for giggles, I decided, hey, maybe I should try converting this image using a separate utility, just to make sure there is nothing wrong with the file. When I then loaded in this file to OpenGL, it worked correctly.
When the file downloaded, I also checked the header again and saw:
od -bc leia-online.dds | head
0000000 104 104 123 040 174 000 000 000 007 020 010 000 356 002 000 000
D D S | \0 \0 \0 \a 020 \b \0 356 002 \0 \0
0000020 024 003 000 000 300 012 011 000 000 000 000 000 001 000 000 000
024 003 \0 \0 300 \n \t \0 \0 \0 \0 \0 001 \0 \0 \0
0000040 111 115 101 107 105 115 101 107 111 103 113 000 000 000 000 000
I M A G E M A G I C K \0 \0 \0 \0 \0
0000060 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000100 000 000 000 000 000 000 000 000 000 000 000 000 040 000 000 000
\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
120 014 000 000
vs the online result of: 300 012 011 000
. According to this indexes 20-23 point to the 'byte count'So basically, my underlying question is this: How do I properly convert a png file to a dds texture using ImageMagick?
Update:
The online imagemagick generated the image header with:
width: 788 height: 750 linearSize: 592576 mipmap_count: 1
My local version of imagemagick generated the image header with:
width: 788 height: 750 linearSize: 3152 mipmap_count: 1
So I wonder if I'm missing a flag somewhere to get it to correctly write the header that the online version might be using?
Upvotes: 3
Views: 2070
Reputation: 315
As it turns out, it was a just a matter of my ImageMagick
version. Upgrading from
ImageMagick 6.8.9-10 Q16 x86_64 2016-09-14 http://www.imagemagick.org
to
ImageMagick 7.0.6-0 Q16 x86_64 2017-06-12 http://www.imagemagick.org
fixed it. Thanks for everyone's help!
Upvotes: 2