This question already has an answer here:
I have a GeoTiff raster in which half of its area is nodata. The problem is that the raster extent includes the nodata area.
Is there a way with GDal to recalculate the extent of the raster excluding the nodata areas?
Thanx to @user30184 here is how to get the raster extent of an image without nodata border.
Replace all nodata pixels with 0 and all other pixels with 1
gdal_calc.py -A source_image.tif --outfile out.tif --NoDataValue 0 --calc="1*(A>0)"
Get the shape file for the meaningful area.
gdal_polygonize.py -8 -b 1 -f "ESRI Shapefile" out.tif pols
Clip the source_image.tif with the shape file to create a new tif with updated extent.
gdalwarp -of GTiff -cutline pols/out.shp -crop_to_cutline -dstalpha 3559007_2014-05-08_RE5_3A_181809processed.tif OUTPUT.tif