Hi again, Some other tricks. To extract the color table from a PNG I often use pngcheck.
pngcheck -p /data/tests/500K_large_pct.png \ | sed '1,2d' \ | awk 'NR < 257' \ | sed 's/[=].*$//' \ | sed 's/[(:)]//g' \ | sed 's/,/ /g' \ | sed 's/...//' > color.txt You could add an extra print command if you want to write it in other format: | awk -F, '{printf "%d,%d,%d,255\n", $1, $2, $3}' To assemble a vrt and a tif I have used gdalbuildvrt command with the argument "-separate". You get a new vrt that You then convert with gdal_translate. Have fun / Lars Schylberg 22 april 2021 kl. 22:50, lars.schylb...@blixtmail.se skrev: > Hi, > > I had to deal a lot with palette tiff images a couple of years ago. > > What I did was that edited the vrt files with sed inline editing: > > Some examples: > > Insert a text file after the row that is: /VRTRasterBand dataType="Byte" > band="1" The inserted file > here is orig_colortable_vrt.txt: > > sed -i -e '/VRTRasterBand dataType="Byte" band="1"/r orig_colortable_vrt.txt' > image_6.vrt > > Remove a certain line that contains "NoDataValue" > > sed -i -e '/NoDataValue/d' image_6.vrt > > There a also a sed commands to delete certain rows. Just read many sed > examples. > > Have fun / Lars Schylberg > > 22 april 2021 kl. 20:25, "Hotmail" <rlela...@hotmail.fr> skrev: > >> Hi all, >> >> I'm looking to modify the original ColorTable, when georeferencing, PNG => >> gdal_translate + >> gdalwarp => TIFF. >> >>> gdal_translate -of VRT -a_srs EPSG:4326 file_png file_vrt -a_ullr xxxx >>> gdalwarp -s_srs EPSG:4326 -t_srs EPSG:3857 file_vrt file_tiff >> >> If I open the VRT file and do the edit manually, the output TIFF file is >> correct. >> The problem is that I have 524288 files ... so I would like to do the >> modification automatically, >> via gdal_translate. >> But I don't quite understand using the parameters of the command ... >> >> • Original VRT & TIFF files >> >> # VRT >> <VRTRasterBand dataType="Byte" band="1"> >> <ColorInterp>Palette</ColorInterp> >> <ColorTable> >> <Entry c1="0" c2="0" c3="255" c4="255" /> >> <Entry c1="255" c2="255" c3="255" c4="255" /> >> <Entry c1="0" c2="0" c3="0" c4="255" /> >> [...] >> <Entry c1="0" c2="0" c3="0" c4="255" /> >> </ColorTable> >> </VRTRasterBand> >> >> # TIFF >> Band 1 Block=63153x1 Type=Byte, ColorInterp=Palette >> Color Table (RGB with 256 entries) >> 0: 0,0,0,255 >> 1: 255,255,255,255 >> 2: 0,0,0,255 >> [...] >> 255: 0,0,0,255 >> >> I want this : >> • Modified VRT and TIFF files >> >> # VRT >> <VRTRasterBand dataType="Byte" band="1"> >> <ColorInterp>Palette</ColorInterp> >> <ColorTable> >> <Entry c1="0" c2="0" c3="255" c4="255" /> >> <Entry c1="0" c2="255" c3="0" c4="255" /> >> <Entry c1="255" c2="0" c3="0" c4="255" /> >> [...] >> <Entry c1="255" c2="0" c3="0" c4="255" /> >> </ColorTable> >> </VRTRasterBand> >> >> # TIFF >> Band 1 Block=63153x1 Type=Byte, ColorInterp=Palette >> Color Table (RGB with 256 entries) >> 0: 0,0,255,255 >> 1: 0,255,0,255 >> 2: 255,0,0,255 >> [...] >> 255: 255,0,0,255 >> >> Whatever I find, redirects me to gdaldem (which I can't use). In >> gdal_translate, it seems to me >> that the parameter -colorinterp_X might be suitable >> but I can't find any concrete examples (or I have not looked in the right >> place). >> >> I want to impose the following parameters: >> Band 1 >> Type = Byte >> ColorInterp = Palette >> Color Table (RGB with 256 entries) >> >> In ColorTable: >> Entry 0 = 0,0,255,255 >> Entry 1 = 0,255,0,255 >> Entries 2 to 255 = 255,0,0,255 >> _______________________________________________ >> gdal-dev mailing list >> gdal-dev@lists.osgeo.org >> https://lists.osgeo.org/mailman/listinfo/gdal-dev > > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev