Opened 17 years ago

Closed 17 years ago

#1796 closed defect (fixed)

[PATCH] JPEGCreateCopy and 1 band palette indexed

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.5.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords: jpeg
Cc:

Description

JPEGCreateCopy only checks for the number of source bands being 1 or 3 and maps 1 band to JCS_GRAYSCALE and 3 bands to JCS_RGB. This is really a minimal check. In the case we have only 1 band but whose color interpretation is GCI_PaletteIndex, we probably prefer to expand it as JCS_RGB rather than JCS_GRAYSCALE.

The enclosed patch implements this.

Attachments (1)

gdal_svn_jpeg_paletteindex.patch (2.3 KB ) - added by Even Rouault 17 years ago.

Download all attachments as: .zip

Change History (7)

by Even Rouault, 17 years ago

comment:1 by Even Rouault, 17 years ago

Component: ConfigBuildGDAL_Raster

comment:2 by warmerdam, 17 years ago

Even,

It is not normal practice for drivers to do paletted to RGB conversion on the fly. I believe a more correct (though less useful) behavior is for the driver to issue either a warning or an error for paletted images. A warning should be issued if bStrict is FALSE, and an error if bStrict is TRUE. If an error is issued, the translation should terminate.

If you feel strongly about drivers doing on-the-fly palette expansion, then I would suggest you raise it as a discussion topic on the mailing list.

comment:3 by Even Rouault, 17 years ago

Yes, I was expecting that this patch is arguable.

I shoud have asked first if there is a way with gdal utilities to do paletted to RGB conversion ? I'm not aware of one.

Another option, that could be probably generalized to other drivers (I can't think of other examples though) , would be to add a creation option like "CONVERT_PALETTE_TO_RGB_IF_NECESSARY".

comment:4 by warmerdam, 17 years ago

Even,

The pct2rgb.py utility can be used to convert pseudocolored images to rgb 24bit 3 band images.

Rather than having drivers do the expansion, I'd rather add options to gdal_translate to do it outside the driver.

comment:5 by Even Rouault, 17 years ago

This is related to #1692

comment:6 by Even Rouault, 17 years ago

Milestone: 1.5.0
Resolution: fixed
Status: newclosed

I've commited in r12377 a simple patch that just warns the user that the source raster band is going to be considered as grey level.

#1692 suggests that this should probably be done in other drivers, but I can't test ECW or JP2K, so I let this one open

Note: See TracTickets for help on using tickets.