Converts a raster object to a JPEG binary stream.
Syntax
bytea ST_AsJPEG(raster raster_obj,
box extent,
integer pyramidLevel default 0,
cstring bands default '',
cstring option default '');Parameters
Parameter | Description |
raster_obj | The raster object to process. |
extent | The extent of the image. By default, a geographic coordinate system is used. |
pyramidLevel | The image pyramid level. The level starts from 0. The default value is 0. |
bands | The list of bands to obtain. Configure the band list based on the number of bands in the JPEG image. The configuration rules are as follows:
|
option | The conversion options in a JSON string. |
The following table describes the fields in the option parameter.
Parameter Name | Description | Type | Default value | Description |
nodata | Specifies whether to process nodata values. | bool | false |
|
nodataValue | The nodata value. | integer | 0 | If nodata is set to true, you must specify a value for this parameter. |
rast_coord | Specifies whether the input box uses pixel coordinates. | bool | false | If pixel coordinates are used, the x-coordinate represents the column number of a pixel and the y-coordinate represents the row number. Both numberings start from 0. |
strength | Specifies whether to apply enhancement. | string | none | The method for display enhancement. Valid values:
|
quality | The compression quality. | integer | 75 | The value ranges from 1 to 100. |
Description
The function returns an image in the `bytea` format.
The default clipping cache is 100 MB, which defines the maximum size of the resulting data. To adjust this limit, set the cache size using the ganos.raster.clip_max_buffer_size parameter.
The number of bands is described as follows:
1: A single band for a grayscale image.
3: Three bands for R, G, and B.
Examples
--Use a clipping extent.
SELECT ST_AsJPEG(raster_obj,
'(-180,-90), (0,0)'::Box)
FROM raster_table
WHERE id =1;
--Specify a pyramid level.
SELECT ST_AsJPEG(raster_obj,
'(-180,-90), (0,0)'::Box,
1)
FROM raster_table
WHERE id =1;
--Specify bands and a clipping extent.
SELECT ST_AsJPEG(raster_obj,
'(-180,-90), (0,0)'::Box,
1,
'0-2')
FROM raster_table
WHERE id =1;
--Use stretching based on statistical values.
SELECT ST_AsJPEG(rast,
'(-180,-90), (0,0)'::Box,
0,
'',
'{"nodata":"false", "nodatavalue":"0","rast_coord":"false", "strength":"stats", "quality":"75"}')
FROM raster_table
WHERE id =1;