Help with finding two scripts to convert .DDS to PNG and back

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Jeff0
Posts: 4
Joined: 2019-02-26T12:14:10-07:00
Authentication code: 1152

Help with finding two scripts to convert .DDS to PNG and back

Post by Jeff0 »

Hi,
I am trying to find a way to convert .DDS files to .PNG, and .PNG to .DDS, while keeping all the channels such as alpha, mipmaps and normalmaps intact.
Does anyone know of a few scripts I could use? I am using Windows 10.

Edit: I thought about doing this:

Code: Select all

convert image1.dds image1.png
But is this the right way to do it? I'd love to hear your suggestions.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with finding two scripts to convert .DDS to PNG and back

Post by fmw42 »

I am not an expert on DDD. See the defines for DDS at https://imagemagick.org/script/formats.php and https://imagemagick.org/script/command- ... php#define, which include those for mipmaps.
Jeff0
Posts: 4
Joined: 2019-02-26T12:14:10-07:00
Authentication code: 1152

Re: Help with finding two scripts to convert .DDS to PNG and back

Post by Jeff0 »

fmw42 wrote: 2019-02-27T13:47:48-07:00 I am not an expert on DDD. See the defines for DDS at https://imagemagick.org/script/formats.php and https://imagemagick.org/script/command- ... php#define, which include those for mipmaps.
Thanks for the reply, I was wondering if you could help me also with a script that scans sub-directories, converts the images, copies the folder structure, and moves it to another folder. E.g, if you have the structure:

Code: Select all

C:\Images\Pictures\ImageFolder\images2***.dds ("images2***.dds" inside "ImageFolder")
             |
             |                                  
             ↓
        images1***.dds ("images1***.dds" Inside "Pictures")
I want to move all the converted .dds to png files after conversion to

Code: Select all

C:\Converted_Images\Images\Pictures(images1***.png)\ImageFolder\(image2***.png)
If you could help me with that that would be great
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with finding two scripts to convert .DDS to PNG and back

Post by fmw42 »

Sorry, I do not code on Windows. But others on this forum do and likely can help you.
Jeff0
Posts: 4
Joined: 2019-02-26T12:14:10-07:00
Authentication code: 1152

Re: Help with finding two scripts to convert .DDS to PNG and back

Post by Jeff0 »

fmw42 wrote: 2019-02-27T15:10:28-07:00 Sorry, I do not code on Windows. But others on this forum do and likely can help you.
Ok, thanks for your help anyway
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help with finding two scripts to convert .DDS to PNG and back

Post by snibgo »

What version of IM? I'll assume v7.
@Jeff0: You seem to have two questions. One is about converting a dds file to png. I know nothing about dds files, but ...

Code: Select all

magick in.dds out.png
... would be a good start.

Your second question is about creating the png file in a different directory. This would be:

Code: Select all

magick inpath\in.dds outpath\out.png
If you have multiple files in multiple directories, you could use a "for" loop for the files and directories, running "magick" for each file. Another possibility is a "for" loop for directories only and "magick mogrify" for each directory. Or "forfiles" for the loop.
snibgo's IM pages: im.snibgo.com
Jeff0
Posts: 4
Joined: 2019-02-26T12:14:10-07:00
Authentication code: 1152

Re: Help with finding two scripts to convert .DDS to PNG and back

Post by Jeff0 »

@snibgo thanks for the tip, I'll be sure to look into it.
Post Reply