Opened 6 years ago

Closed 6 years ago

#5555 closed defect (fixed)

Traceback in pct2rgb.py

Reported by: reffettc Owned by: warmerdam
Priority: normal Milestone: 1.11.1
Component: Utilities Version: 1.11.0
Severity: normal Keywords: pct2rgb
Cc:

Description

When running pct2rgb.py on the attached file, the following Python traceback is triggered:

Traceback (most recent call last):

File "./pct2rgb.py", line 133, in <module>

entry = ct.GetColorEntry?(i)

File "/usr/lib64/python2.6/site-packages/GDAL-1.11.0-py2.6-linux-x86_64.egg/osgeo/gdal.py", line 1342, in GetColorEntry?

return _gdal.ColorTable?.GetColorEntry?(self, *args)

SystemError?: error return without exception set

This appears to be related to line 125 of pct2rgb.py, which sets ct_size as max(256, ct.GetCount?()). I suspect that my image file has fewer than 256 colors in the color table, which is triggering the traceback, but I can't be certain of it. I changed that line to min(256, ct.GetCount?()) and it works right, though I see that that line was changed in this version specifically to allow more than 256 colors.

Attachments (1)

02ebk013.tl4 (288.3 KB) - added by reffettc 6 years ago.

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by reffettc

Attachment: 02ebk013.tl4 added

comment:1 Changed 6 years ago by reffettc

As a further note, this happens with all of the images I am trying to convert, I just uploaded the one image as a sample. I can't change the images themselves to have >= 256 colors since this is part of a script that will use customer-furnished data.

comment:2 Changed 6 years ago by Even Rouault

Component: defaultUtilities
Keywords: pct2rgb added
Milestone: 1.11.1
Resolution: fixed
Status: newclosed

Thanks for the report. The fix done in 1.11 fixed images with more than 256 values in the color table, but unfortunately broke the case where there are less than 256 values, which is the case for all CADRG tiles.

trunk r27489, branches/1.11 r27490 : "pct2rgb.py: make it work (again) with color tables with less than 256 entries (#5555)"

You can use the fixed version at http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/pct2rgb.py

Note: See TracTickets for help on using tickets.