[gdal-dev] warp/trsnalte a specific src_ovr without alpha band
Even Rouault
even.rouault at spatialys.com
Sun Jul 7 02:37:53 PDT 2019
On dimanche 7 juillet 2019 12:13:04 CEST Idan Miara wrote:
> Hi,
>
> I have a RGBA raster with overviews, I'd like to cut an extent from a
> specific overview into a new YCbCr JPEG raster.
> I want to drop the alpha band (I don't need it and it is not supported in
> YCbCr).
>
> I couldn't find a way to do it because:
> 1. with gdal_translate I could choose bands (RGB) but I couldn't given a
> src_ovr,
You can do it in 2 steps. Note the size of the overview you are interested in.
Imagine that in.tif has dimensions 21x13 and an overview of 11x7
Do:
gdal_translate in.tif ovr.vrt -outsize 11 7 -of VRT -b 1 -b 2 -b 3
gdal_translate ovr.vrt extract.tif [-srcwin | -projwin] -co COMPRESS=JPEG -co
PHOTOMETRIC=YCBCR
~~~
Or you can do it in one step by using the generic OVERVIEW_LEVEL open option.
See the papszOpenOptions of
https://gdal.org/api/raster_c_api.html#_CPPv410GDALOpenExPKcjPPCKcPPCKcPPCKc
If the overview level you're interested in is the first one (index 0), then
gdal_translate in.tif extract.tif -b 1 -b 2 -b 3 [-srcwin | -projwin] -co
COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -oo OVERVIEW_LEVEL=0
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list