dds to png conversion colors wrong

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
videomike99
Posts: 5
Joined: 2016-04-28T11:49:49-07:00
Authentication code: 1151

dds to png conversion colors wrong

Post by videomike99 »

Hi All.
I'm new to ImageMagick, and am trying to convert an existing .dds image to .png, (or anything else for that matter).
Here's my command string:
convert colorbars.dds -set colorspace ycbca -colorspace rgb newfile.png

The original image can be found here: http://www.video-impressions.com/images/colorbars.dds

All of my conversion attempts either come out purple-ish, or green-ish, so I'm guessing it's a channel thing, but I'm just not that familiar with the program yet.

Any help would be appreciated.
Thanks,

Mike
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: dds to png conversion colors wrong

Post by dlemstra »

What is your operating system and your ImageMagick version? And what is wrong with the output? It does contain green-ish and purple-ish values. Can you post your output somewhere?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
videomike99
Posts: 5
Joined: 2016-04-28T11:49:49-07:00
Authentication code: 1151

Re: dds to png conversion colors wrong

Post by videomike99 »

Windows 7 64bit
ImageMagick -6.9.3-Q16
Input file: http: http://www.video-impressions.com/images/colorbars.dds
Output file: http://www.video-impressions.com/images/newfile.png
What file should look like: http://www.video-impressions.com/images/ColorBars.png

The output is purple-ish when opened in photoshop.

Thanks for your assistance!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: dds to png conversion colors wrong

Post by fmw42 »

convert colorbars.dds -set colorspace ycbca -colorspace rgb newfile.png
Is ycbca a type? Should it not be YCbCr? Also you should be using -colorspace srgb (for current versions of IM).

Code: Select all

convert colorbars.dds -set colorspace ycbcr -colorspace srgb newfile.png
Nevertheless, the above does not convert to match your colorbars.png on IM 6.9.3.8 Q16 Mac OSX. So are you sure the input DDS is really colorspace YCbCr?
videomike99
Posts: 5
Joined: 2016-04-28T11:49:49-07:00
Authentication code: 1151

Re: dds to png conversion colors wrong

Post by videomike99 »

Sorry...I had a typo. :?
Below is the command string:

convert colorbars.dds -set colorspace ycbcr -colorspace rgb newfile.png

I've also tried:

convert colorbars.dds -set colorspace ycbcra -colorspace rgb newfile.png
videomike99
Posts: 5
Joined: 2016-04-28T11:49:49-07:00
Authentication code: 1151

Re: dds to png conversion colors wrong

Post by videomike99 »

I'm not sure what the original colorspace is, so I've tried just about every one, as well as omitting the value and going with the default as well.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: dds to png conversion colors wrong

Post by snibgo »

After the image has been read, the colorspace is similar to YCbCr, but in the order CbYCr so we need to swap the first two channels.

Code: Select all

convert colorbars.dds -separate -swap 0,1 -combine -set colorspace YCbCr -colorspace sRGB x2.png
The result is close to the required colour chart, but not exactly the same.
snibgo's IM pages: im.snibgo.com
videomike99
Posts: 5
Joined: 2016-04-28T11:49:49-07:00
Authentication code: 1151

Re: dds to png conversion colors wrong

Post by videomike99 »

That's great...now it just seems like a gamma issue maybe...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: dds to png conversion colors wrong

Post by snibgo »

Sadly, no, it isn't just a gamma issue. My result gives "gray" patches that have slightly different values in the three channels.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: dds to png conversion colors wrong

Post by fmw42 »

snibgo wrote:After the image has been read, the colorspace is similar to YCbCr, but in the order CbYCr so we need to swap the first two channels.
snibgo, I am just curious. I do not know DDS image format, so I am curious how you knew the channels were swapped. Are the Cb and Cr channels much different from the Y channel in values? Or was it just a guess on the way the colors seemed swapped?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: dds to png conversion colors wrong

Post by snibgo »

I know nothing about DDS.

After a simple "convert in.dds out.tiff" conversion, I looked at the pixel values in the bars that should be varying lightnesses of gray, using an image editor with eyedropper. The first and last channels were around 50%, with the middle value varying. So the middle channel seemed to be luminance or Y. I tried all the Y?? colorspaces and YCbCr seemed the closest fit.

I don't know if IM's DDS reader does any colorspace conversion, or re-arrangement of channels. dds.c is quite complex.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: dds to png conversion colors wrong

Post by fmw42 »

snibgo,

You said that you used

Code: Select all

convert colorbars.dds -separate -swap 0,1 -combine -set colorspace YCbCr -colorspace sRGB x2.png
and that did not quite work out. Had you tried swapping Cb and Cr along with moving Y to the middle channel, i.e.

Code: Select all

convert colorbars.dds -separate -swap 1,2 -combine -set colorspace YCbCr -colorspace sRGB x2.png
If so, was that better or worse?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: dds to png conversion colors wrong

Post by snibgo »

Of the possible arrangement of channels Y-Cb-Cr, the one that fits best is Cb-Y-Cr. All other arrangements are clearly worse.

@videomike99: What software created colorbars.dds, or where did you get it from?
snibgo's IM pages: im.snibgo.com
Post Reply