0

I am trying to convert some ECW files to PNG using the command gdal_translate test.ecw -of png test.png, but the PNG file comes out grayscale.

How do I produce a colored PNG from an ECW file using this tool?

Output from gdalinfo test.ecw:

Driver: ECW/ERDAS Compressed Wavelets (SDK 3.x)
Files: test.ecw
Size is 16000, 24000
Coordinate System is:
PROJCRS["ETRS89 / UTM zone 32N",
    BASEGEOGCRS["ETRS89",
        DATUM["European Terrestrial Reference System 1989",
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4258]],
    CONVERSION["UTM zone 32N",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",9,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["easting",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["northing",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    ID["EPSG",25832]]
Data axis to CRS axis mapping: 1,2
Origin = (448000.000000000000000,6283000.000000000000000)
Pixel Size = (0.125000000000000,-0.125000000000000)
Metadata:
  COLORSPACE=MULTIBAND
  COMPRESSION_RATE_TARGET=4
  VERSION=2
Corner Coordinates:
Upper Left  (  448000.000, 6283000.000) (  8d 9' 3.88"E, 56d41'17.50"N)
Lower Left  (  448000.000, 6280000.000) (  8d 9' 6.06"E, 56d39'40.48"N)
Upper Right (  450000.000, 6283000.000) (  8d11' 1.41"E, 56d41'18.29"N)
Lower Right (  450000.000, 6280000.000) (  8d11' 3.51"E, 56d39'41.27"N)
Center      (  449000.000, 6281500.000) (  8d10' 3.71"E, 56d40'29.39"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #0
  Overviews: 8000x12000, 4000x6000, 2000x3000, 1000x1500, 500x750, 250x375
Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #1
  Overviews: 8000x12000, 4000x6000, 2000x3000, 1000x1500, 500x750, 250x375
Band 3 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #2
  Overviews: 8000x12000, 4000x6000, 2000x3000, 1000x1500, 500x750, 250x375
Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #3
  Overviews: 8000x12000, 4000x6000, 2000x3000, 1000x1500, 500x750, 250x375
Band 5 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #4
  Overviews: 8000x12000, 4000x6000, 2000x3000, 1000x1500, 500x750, 250x375
7
  • What happens if you translate to JPEG2000 instead?
    – wingnut
    Commented May 14, 2021 at 14:37
  • @KadirŞahbaz I've done that now
    – user183474
    Commented May 14, 2021 at 14:54
  • @wingnut gdal_translate tells me that the JPEG2000 driver is deprecated. If I suppress the message, I get "0ERROR 1: Unable to write scanline 0 of the component 0."
    – user183474
    Commented May 14, 2021 at 14:57
  • Add gdalinfo report about the source image. Why do you want to create output as PNG? It is very bad GIS format for big images.
    – user30184
    Commented May 14, 2021 at 19:07
  • @user30184 Done. Because I need to use the images in some software that only support PNG.
    – user183474
    Commented May 15, 2021 at 13:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.