Schema
Owner
postgres
Descriptions
args: rast, options=NULL - Return the raster tile selected bands as a single Joint Photographic Exports Group (JPEG) image (byte array). If no band is specified and 1 or more than 3 bands, then only the first band is used. If only 3 bands then all 3 bands are used and mapped to RGB.
Options
Option | Value |
---|---|
Returns |
bytea |
Language |
|
Parameters |
rast public.raster options text [] = NULL::text[] |
Definition
CREATE OR REPLACE FUNCTION public.st_asjpeg (
rast public.raster,
options text [] = NULL::text[]
)
RETURNS bytea AS
$span$
DECLARE
rast2 raster;
num_bands int;
i int;
BEGIN
IF rast IS NULL THEN
RETURN NULL;
END IF;
num_bands := st_numbands($1);
-- JPEG allows 1 or 3 bands
IF num_bands <> 1 AND num_bands <> 3 THEN
RAISE NOTICE 'The JPEG format only permits one or three bands. The first band will be used.';
rast2 := st_band(rast, ARRAY[1]);
num_bands := st_numbands(rast);
ELSE
rast2 := rast;
END IF;
-- JPEG only supports 8BUI pixeltype
FOR i IN 1..num_bands LOOP
IF st_bandpixeltype(rast, i) != '8BUI' THEN
RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.', i;
END IF;
END LOOP;
RETURN st_asgdalraster(rast2, 'JPEG', $2, NULL);
END;
$span$
LANGUAGE 'plpgsql'
IMMUTABLE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
COMMENT ON FUNCTION public.st_asjpeg(rast public.raster, options text [])
IS 'args: rast, options=NULL - Return the raster tile selected bands as a single Joint Photographic Exports Group (JPEG) image (byte array). If no band is specified and 1 or more than 3 bands, then only the first band is used. If only 3 bands then all 3 bands are used and mapped to RGB.';
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23 |