Converting TIF to indexed PCX colour issue

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
danc81
Posts: 7
Joined: 2012-01-23T12:18:56-07:00
Authentication code: 8675308

Converting TIF to indexed PCX colour issue

Post by danc81 »

Hi,

I'm working on replacing a GIMP-based script with ImageMagick and I'm having some problems with image conversion.

The process is required to take an input TIF image and convert to a PCX image tile. The tile appears to export OK but does not look correct when loaded by the application it's being converted for whereas the one created in GIMP does. Now, the main difference I can see between the output is the number of colours and that's what's confusing me.

The GIMP version does the following:

gimp-image-convert-indexed newimg 0 0 64 0 0 "<file path>"

Which produces a file when viewed with 'identify -verbose' with the following colour information:

Colors: 64
Histogram:
183: ( 0, 89,182) #0059B6 srgb(0,89,182)
431: ( 0,101,186) #0065BA srgb(0,101,186)
692: ( 1, 2, 0) #010200 srgb(1,2,0)
65: ( 11, 16, 19) #0B1013 srgb(11,16,19)
394: ( 14,114,192) #0E72C0 srgb(14,114,192)
<snip rest of the 64 colours>

Now, I'm doing the same conversion with ImagMagick with the following command line:

convert -colorspace RGB -colors 256 -depth 8 -extract 200x200+2200+0 "<input file>" "<output file>.pcx"

And that produces the following:

Colors: 8
Histogram:
2233: ( 0, 0, 0) #000000 black
1947: ( 0,101,186) #0065BA srgb(0,101,186)
518: (148,148,148) #949494 grey58
2174: (193, 58, 61) #C13A3D srgb(193,58,61)
10491: (206,227,244) #CEE3F4 srgb(206,227,244)
80: (255,227, 28) #FFE31C srgb(255,227,28)
282: (255,255, 0) #FFFF00 yellow
22275: (255,255,255) #FFFFFF white

Now the main difference I can see here is that the colours is 8 on the ImageMagick version and 64 on the GIMP version.

I've tried switching to -colors 64, I've tried removing the -colorspace argument and various combinations of arguments always with the same results.

The input file is the same in both cases and it's an RGB TIF file.

Where am I going wrong?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting TIF to indexed PCX colour issue

Post by fmw42 »

Have you tried using IM 6 syntax by reading the image first. It may not make a difference, though, but worth checking. Also what version of IM and platform are you using?

convert -extract 200x200+2200+0 "<input file>" -colorspace RGB -colors 256 -depth 8 "<output file>.pcx"

see
http://www.imagemagick.org/Usage/basics/#cmdline


Also see
viewtopic.php?f=3&t=16659&p=61513&hilit=PCX#p61513


I don't know if that has changed or not? The IM developers would have to comment here.
danc81
Posts: 7
Joined: 2012-01-23T12:18:56-07:00
Authentication code: 8675308

Re: Converting TIF to indexed PCX colour issue

Post by danc81 »

Thanks, I did try it that way round but it didn't make any difference to the output unfortunately.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting TIF to indexed PCX colour issue

Post by fmw42 »

Also see
viewtopic.php?f=3&t=16659&p=61513&hilit=PCX#p61513

I don't know if that has changed or not? The IM developers would have to comment here.
Post Reply