0

This question already has an answer here:

I'm using gdalwarp -dstalpha src.tif dst.tif to add alpha channel to an 8-bit unsigned image with 3 bands. The initial size of the image is 300 mb, but adding an alpha band increases it to 1980 mb, which is far more than expected 1/4 increase.

What is the matter?

marked as duplicate by user2856, nmtoken, xunilk, JGH, Kersten Dec 17 '17 at 10:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The original image is probably compressed and you write out an uncompressed image. Check with gdalinfo and use suitable -co compress= option. – user30184 Dec 16 '17 at 14:24
  • 1
    Could you please provide your full gdalwarp call? – onakua Dec 16 '17 at 16:09
  • Yeah that is my concern. If his gdalwarp call involved clipping (instead of simply adding an alpha band) it will result in file inflation, which as you mention is duplicate. – onakua Dec 16 '17 at 22:02
  • @onakua I don't think it matters, solution is the same: gdalwarp -of VRT -dstalpha src.tif dst.vrt && gdal_translate -co compress=whatever dst.vrt dst.tif – user2856 Dec 16 '17 at 22:11