Ticket #1939 (closed defect: fixed)

Opened 11 months ago

Last modified 2 months ago

Conversion of paletted PNG to ECW does not work

Reported by: jcrepetto Assigned to: mloskot
Priority: normal Milestone: 1.6.0
Component: GDAL_Raster Version: 1.4.2
Severity: normal Keywords: ecw color table expansion
Cc: warmerdam

Description

When I convert a paletted PNG file to ECW, the resulting image is almost black, as if the compression was made using the indexes instead of the real colours.

Example:

gdal_translate -of ECW -co "TARGET=94%" -co "DATUM=NTF"  -co "PROJ=LM1FRA2D" -a_ullr 970000 1860000 980000 1850000 test.png test.ecw

There is no problem with a true colour PNG image.

Expected result

- Either GDAL should do the 8-bit to 24-bit conversion as part of the format translation (for convenience and to save on temporary disk space)
- Or at least produce an error message that paletted files are not supported, and stop. GDAL should not produce a wrong result, it would save a lot of time to users.

Note : This topic has been discussed on the GDAL-dev ML, on 19 Dec 2006 and 3 Jul 2007.

Attachments

gdal_svn_trunk_bug_1939_1692.patch (3.9 kB) - added by rouault on 11/27/07 14:32:52.

Change History

10/25/07 09:10:24 changed by warmerdam

  • keywords set to ecw.
  • owner changed from warmerdam to mloskot.
  • component changed from default to GDAL_Raster.
  • cc set to warmerdam.
  • milestone set to 1.5.0.

I concur, the ECWCreateCopy() function should error out if the source image is paletted and bStrict is set to TRUE. If bStrict is FALSE and the source image has a palette the function should issue a warning and proceed as it does now.

Mateusz, could you take care of this as time permits?

This pattern should be applied in a variety of other drivers too. It might make sense to bundle up the logic in a support function. We also really ought to have a way of declaring in the driver metadata whether the driver supports writing paletted images, but I think we will not try and address that at this time.

10/25/07 13:43:44 changed by rouault

This is another duplicate of #1692 and #1796 (JPEG driver is affected too)

I think that expected result for most users would be proposal number 1 : 8bit --> 24bit implicit conversion. I don't really see why/when it would not be a good idea, from a user point of view, to do the implicit conversion when we have 1 source band and that its color interpretation is palette index or greylevel. For example, convert (from ImageMagick? tool suite) automatically converts 8bit GIF to 24bit JPG.

Now, from a developer point of view, it needs some work of course ;-) and there's still the workaround with an intermediate pct2rgb.

10/25/07 16:39:05 changed by warmerdam

Even,

If we are going to have drivers CreateCopy?() functions do palette to RGB conversion on the fly, I think that should be proposed as an RFC for discussion and vote. For now, it is not the expected (or to my mind preferred) behavior of GDAL drivers.

11/27/07 14:32:19 changed by rouault

Patch attached that checks for the presence color table on band 1 and warns/fails for ECW, MrSID, JPG and JPEG2000. Maybe some other drivers are missing. I didn't really see the added value of a support function for that, especially if we decide one day to do palette expansion on the fly. (Coudl't test if it compiles fine for MrSID and ECW drivers)

11/27/07 14:32:52 changed by rouault

  • attachment gdal_svn_trunk_bug_1939_1692.patch added.

02/06/08 11:56:23 changed by warmerdam

  • milestone changed from 1.5.1 to 1.6.0.

Even,

The patch looks good to me. Could you please attach it in trunk?

I don't see the need for this to go into 1.5.1.

02/06/08 15:06:06 changed by rouault

  • status changed from new to closed.
  • resolution set to fixed.

Patch commited in trunk in r13715

07/04/08 15:04:54 changed by rouault

  • keywords changed from ecw to ecw color table expansion.

In r14806, I've commited the final fix for this issue by providing a proxy dataset that does color table expansion. It also adds a -expand option to gdal_translate to take benefit of it.