Opened 9 years ago
Closed 9 years ago
#5761 closed defect (fixed)
gdalwarp zeroes all alpha pixels from grey+alpha image
Reported by: | cdestigter | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: |
Description (last modified by )
When warping a grey+alpha image, gdal appears to zero out all the alpha pixels, resulting in a completely invisible image.
test case:
gdalinfo -stats ~/c/in.tif | grep Minimum rm -f ~/c/out.tif* ; gdalwarp ~/c/in.tif ~/c/out.tif gdalinfo -stats ~/c/out.tif | grep Minimum
Minimum=0.000, Maximum=176.000, Mean=86.546, StdDev=59.195 Minimum=0.000, Maximum=255.000, Mean=176.375, StdDev=117.760 Creating output file that is 16P x 15L. Processing input file /Users/cdestigter/c/in.tif. 0...10...20...30...40...50...60...70...80...90...100 - done. Minimum=0.000, Maximum=176.000, Mean=86.546, StdDev=59.195 Minimum=0.000, Maximum=0.000, Mean=0.000, StdDev=0.000
Adding -setci doesn't help. If I add -dstalpha I get a good alpha band in band 3, but then I have to remove band 2 somehow.
Tested on both stock 1.11.0 and trunk (r28101), occurs on both.
Attached in.tif.
Attachments (1)
Change History (5)
by , 9 years ago
comment:1 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 9 years ago
Description: | modified (diff) |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
This *is* actually a real bug, I just wasn't on my game the other day.
I updated the above instructions to reproduce the actual bug.
comment:3 by , 9 years ago
I managed to make it work with the following sequence:
gdal_translate in.tif in.vrt -of vrt python -c "from osgeo import gdal; ds = gdal.Open('in.vrt', gdal.GA_Update); ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_AlphaBand); ds = None" gdalwarp in.vrt out.tif -overwrite -setci
There are 2 issues :
- the color interpretation of band 2 of in.tif is "Undefined". This is what the first 2 following steps fix.
- By default, gdalwarp doesn't explictely set the color interpretation of the target dataset. But a Grey+Alpha geotiff isn't the default configuration of the geotiff driver for 2 bands, hence the need for -setci (or alternatively -co ALPHA=YES)
comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Note that I've done an enhancement in trunk : r28102 "GeoTIFF: set alpha on target by default when translating from Grey+Alpha"
So I don't think there's any further action needed.
d'oh. User error! I wasn't removing out.tif.aux.xml which contained saved stats. Disregard :)