ST_AsTIFF — Return the raster selected bands as a single TIFF image (byte array). If no band is specified or any of specified bands does not exist in the raster, then will try to use all bands.
bytea ST_AsTIFF(raster rast, text options='', integer srid=sameassource
bytea ST_AsTIFF(raster rast, text compression='', integer srid=sameassource
bytea ST_AsTIFF(raster rast, integer nbands, text compression='', integer srid=sameassource
bytea ST_AsTIFF(raster rast, integer nbands, text options, integer srid=sameassource
Returns the selected bands of the raster as a single Tagged Image File Format (TIFF). If no band is specified, will try to use all bands. This is a wrapper around ST_AsGDALRaster. Use ST_AsGDALRaster if you need to export as less common raster types. There are many variants of the function with many options. If no spatial reference SRS text is present, the spatial reference of the raster is used. These are itemized below:
nbands is an array of bands to export (note that max is 3 for PNG) and the order of the bands is RGB. e.g ARRAY[3,2,1] means map band 3 to Red, band 2 to green and band 1 to blue
compression Compression expression -- JPEG90 (or some other percent), LZW, JPEG, DEFLATE9.
srid srid of spatial_ref_sys of the raster. This is used to populate the georeference information
Availability: 2.0.0 - requires GDAL >= 1.6.0.
SELECT ST_AsTIFF(rast, 'JPEG90') As rasttiff FROM dummy_rast WHERE rid=2;